bean:parameter

 < Day Day Up > 



<bean:parameter />

The <bean:parameter /> tag is used to retrieve the value of a request parameter identified by the name attribute. The retrieved value will be used to define a page scoped attribute of type java.lang.String or String[], if the multiple attribute is not null. The <bean:parameter /> tag has no body and supports four attributes, as shown in Table 20.7.

Table 20.7: <bean:parameter /> Tag Attributes

Attribute

Description

id

Represents the name of the scripting variable that will be exposed as a page scoped attribute. (Required)

name

Identifies the name of the request parameter being retrieved. (Required)

multiple

If not null, causes a String[] containing all of the parameter values for the named request parameter to be returned as opposed to a single parameter. If the multiple attribute is not null and there is only a single parameter value, then the first or [0] element of the String[] will contain the retrieved value. (Optional)

value

Specifies the default value to return and store in the name object, if the named parameter is not found. (Optional)

An example of using the <bean:parameter /> tag is shown here:

 <bean:parameter    name="username"   value="User Not Found" /> 

In this example, we are looking for the request parameter username. If the username parameter exists in the request, then a String object containing the retrieved value is created and stored in the page; otherwise, a String object containing the String named in the value attribute-User Not Found in this example-is created and stored in the page.



 < Day Day Up > 



Professional Jakarta Struts
Professional Jakarta Struts (Programmer to Programmer)
ISBN: 0764544373
EAN: 2147483647
Year: 2003
Pages: 183

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