O'Reilly logo

Java EE 7 Developer Handbook by Peter A. Pilgrim

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Request and response

For Servlets to be useful, we need to read the HTTP request, and then generate a response. HTTP Servlets provide two types of instances: HttpServletRequest and HttpServletResponse.

The request parameters

The Servlet framework decodes the HTTP protocol parameters sent by the client into a specific map of key and values. The methods on HttpServletRequest to access these parameters are getParameter(), getParameterNames(), and getParameterMap(). The getParameter() method returns the first value in an array of the query string data values. This is because the HTTP standard allows an HTTP request to be formed with multiple parameter associations.

To retrieve a CGI query data in a URI, such as /fooAction?name=Mary&bus=249, we can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required