The difference between request.getparametervalues and Request.getparameter

Source: Internet
Author: User

A simple control

Request.getparameter used more, relatively familiar

Request.getparametervalues (String name) is to obtain data such as the CheckBox class (with the same name, but with multiple values). Receive array variables, such as the CHECKOBX type
Request.getparameter (String name) is the data that obtains the corresponding name, assuming that there is a repeating name, the first value is returned. Receive generic variables, such as the text type

Cases:

1. Three names the same text label


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


The so-called hidden object, when writing a JSP Web page, do not have to do whatever the declaration can be directly used objects. JSP2.0 defines nine hidden objects

Request Response PageContext Session application out CONIFG page exception

Here's just a mention of request and response two objects

The Request object represents what the client requested, for example, we 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 two methods of request getparameter and getparametervalues, in fact the request has several other important methods, here are only a few ways to get the request parameters

String GetParameter (string name) gets the value of name

String[] Getparametervalues (String name) gets the full name of the number of references

Enumeration Getparameternames () obtains all the name of the participant

Map<string, string[]> Getparametermap () gets a map of all the parameters of the 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 an important identity, and have the opportunity to specialize and publicize their illustrious status.

2. El Hidden Objects

El is experssion Language, since JSP2.0 formally become one of the standard specification of JSP, support servlet2.4/jsp2.0 container also corresponds to support El syntax.

A common form such as <c:out value= "${3 + 7 * 4}"/>

El's Hidden object has 11 PageContext pagescope requestscope sessionscope applicationscope

Param paramvalues Header headervalues Cookie Initparam

where Param and paramvalues correspond to Servletrequest.getparameter (string name) and Servletrequest.getparametervalues (string name)

This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/moreorless/archive/2009/05/18/4199677.aspx

The difference between request.getparametervalues and Request.getparameter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.