Sunday, 26 June 2016

How to retrieve HTML form parameters from the request ?


All form data from both the query string + post body are aggregated into the request parameter set.
The parameters sent in URI query string are stored by the servlet container as a set of name/value pairs.


Multiple parameter values can exist for any given parameter name. (Like, a=123&a=567)
 

Methods in ServletRequest interface
  • getParameter : returns value for a given parameter
  • getParameterNames : returns array of all names of parameters (No value)
  • getParameterValues : returns an array of String objects containing all the parameter values associated with a parameter name

Scenario : 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)

No comments:

Post a Comment

Note: only a member of this blog may post a comment.