bean:header

 < Day Day Up > 



<bean:header />

The <bean:header /> tag functions exactly like <bean:cookie />, except that it retrieves its values from the named request header. Once the tag has the header values, it creates a java.lang.String or java.lang.String[] attribute and stores it in the PageContext.

If the named header cannot be located and no default value is given, then a request-time exception will be thrown. The <bean:header /> tag has a body type of JSP and supports four attributes, described in Table 20.3.

Table 20.3: <bean:header /> 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 HTTP header being retrieved. (Required)

multiple

If not null, causes a String[] containing all of the header values for the named HTTP header to be returned as opposed to a single header. If the multiple attribute is not null and there is only a single HTTP header, 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 header is not found. (Optional)

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

 <bean:header    name="Cache-Control"   value="Cache-Control Not Found" /> 

In this example, we are looking for a HTTP header, Cache-Control. If the Cache-Control header exists, 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--Cache-Control 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