QuestionQ31

VerifiedSecure Coding Practices for Input Validation

Assume a productList.jsp page displays products from the database for the requested product category. The product category is supplied as a request-parameter value. Which line of code should be used to strictly validate the request-parameter value before processing it for execution?

Explanation

Strict input validation uses an allow-list regular expression such as ^[a-zA-Z0-9]*$ together with Matcher.matches(), which succeeds only when the entire input contains permitted alphanumeric characters. Retrieving a parameter or checking only whether it is non-null does not validate its contents. Oracle’s Java API specifies that Matcher.matches() attempts to match the entire input region against the pattern.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!