First, the simple contrast
Request.getparameter used more, relatively familiar
Request.getparametervalues (String name) is to obtain data such as the CheckBox class (with the same name but multiple values). Receive array variables , such as the CHECKOBX type
Request.getparameter (String name) is the data that obtains the corresponding name, and if there is a duplicate name, the first value is returned. Receive generic variables , such as the text type
Cases:
1. Three text labels with the same name
<input type= "text" name= "test" value= "1"/>
<input type= "text" name= "test" value= "2"/>
<input type= "text" name= "Test" value= "3"/>
Request.getparametervalues ("test")-----------------[1, 2, 3]
Request.getparameter ("Test")------------------1
${paramvalues.test}
${param.test}
2. checkbox
<input type= "checkbox" Name= "Habit" value= "read" > Reading
<input type= "checkbox" Name= "Habit" value= "movie" > Movies
<input type= "checkbox" Name= "Habit" value= "game" > Games
Request.getparametervalues ("Habit")
Ii. topics related to this------hidden objects
1. JSP hidden Objects (implicit object)
An implied object is an object that can be used directly when writing a JSP Web page without having to make any declarations. JSP2.0 defines nine hidden objects
Request Response PageContext Session application out CONIFG page exception
Here, just mention the request and response two objects
The Request object represents the content requested by the client, for example, we have obtained the user input from the request and implemented the Javax.servlet.http.HttpServletRequest interface
The response object represents the result of the response client.
Above we used the request of the two methods GetParameter and getparametervalues, in fact, request there are several other important methods, here are only a few ways to get the request parameters
String GetParameter (string name) gets the parameter value of name
String[] Getparametervalues (String name) gets the parameter value of all name
Enumeration Getparameternames () get all the parameter names
Map<string, string[]> Getparametermap () get a map of all parameters of request
//
-
Returns a java.util.Map of the parameters of this request. Request parameters is extra information sent with the request. For HTTP Servlets, parameters is contained in the query string or posted form data.
-
-
Returns:
An
-
immutable java.util.Map containing parameter names as keys and parameter values as MAP values. The keys in the parameter map is of type String. The values in the parameter map is of type String array.
//
Several other hidden objects, such as response, also have a very important identity, and have the opportunity to specialize and publicize their illustrious status.
2. El Hidden Objects
El namely Experssion Language, since JSP2.0 formally become one of the standard specification of JSP, support servlet2.4/jsp2.0 container also support El syntax accordingly.
A common form such as <c:out value= "${3 + 7 * 4}"/>
El's Hidden object has 11 PageContext pagescope requestscope sessionscope applicationscope
param paramvaluesheader headervalues Cookie Initparam
where Param and paramvalues are the corresponding Servletrequest.getparameter (string name) and Servletrequest.getparametervalues (string name)
The difference between request.getparametervalues and Request.getparameter