DEVFYI - Developer Resource - FYI

Request parameter How to find whether a parameter exists in the request object?

Servlet Interview Questions and Answers


(Continued from previous question...)

10. Request parameter How to find whether a parameter exists in the request object?

1.boolean hasFoo = !(request.getParameter("foo") == null || request.getParameter("foo").equals(""));
2. boolean hasParameter = request.getParameterMap().contains(theParameter);
(which works in Servlet 2.3+)

(Continued on next question...)

Other Interview Questions