SRV.5.1 Parameters


Request parameters are strings sent by the client to a servlet container as part of a request. When the request is a HttpServletRequest , the attributes are populated from the URI query string and possibly posted form data. The parameters are stored by the servlet container as a set of name-value pairs. Multiple parameter values can exist for any given parameter name . The following methods of the ServletRequest interface are available to access parameters:

  • getParameter

  • getParameterNames

  • getParameterValues

The getParameterValues method returns an array of String objects containing all the parameter values associated with a parameter name. The value returned from the getParameter method must always equal the first value in the array of String objects returned by getParameterValues .

All form data from both the query string and the post body are aggregated into the request parameter set. The order of this aggregation is that query string data takes precedence over post body parameter data. For example, if a request is made with a query string of a=hello and a post body of a= goodbye &a=world , the resulting parameter set would be ordered a=(hello, goodbye, world) .

Posted form data is read from the input stream of the request and used to populate the parameter set only when all of the following conditions are met:

  1. The request is an HTTP or HTTPS request.

  2. The HTTP method is POST.

  3. The content type is application/x-www-form-urlencoded .

  4. The servlet calls any of the getParameter family of methods on the request object.

If any of the getParameter family of methods is not called, or not all of the above conditions are met, the post data must remain available for the servlet to read via the request's input stream.



Java 2 Platform, Enterprise Edition. Platform and Component Specifications
Java 2 Platform, Enterprise Edition: Platform and Component Specifications
ISBN: 0201704560
EAN: 2147483647
Year: 2000
Pages: 399

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net