The REQUEST custom tag library contains tags which can be used to access all the information about the HTTP request for a JSP page.
Tags are provided to access information in the HTTP request for HTTP input parameters from a POST or GET, HTTP Headers, Cookies, request attributes, and session information related to this request.
This custom tag library requires no software other than a servlet container that supports the JavaServer Pages Specification, version 1.1 or higher.
Follow these steps to configure your web application with this tag library:
<taglib> <taglib-uri>http://jakarta.apache.org/taglibs/request-1.0</taglib-uri> <taglib-location>/WEB-INF/request.tld</taglib-location> </taglib>
To use the tags from this library in your JSP pages, add the following directive at the top of each page:
<%@ taglib uri="http://jakarta.apache.org/taglibs/request-1.0" prefix="req" %>
where "req" is the tag name prefix you wish to use for tags from this library. You can change this value to any prefix you like.
log | Log the body of the tag to the servlet context log. |
request | Get information about current HTTP request. |
isSecure | Test whether the HTTP connection is secure (using HTTPS). |
isSessionFromCookie | Test whether the HTTP session was from a cookie. |
isSessionFromUrl | Test whether the HTTP session was from URL encoding. |
isSessionValid | Test whether the HTTP session is valid. |
isUserInRole | Test whether the remote user is in a role. |
attribute | Get the value of a single request attribute. |
attributes | Loop through all request attributes. |
equalsAttribute | See if a request attribute equals some value. |
existsAttribute | See if a request attribute exists. |
removeAttribute | Removes an attribute from a request. |
setAttribute | Sets the value of a request attribute. |
cookie | Get the value of a single request cookie. |
cookies | Loop through all request cookies. |
equalsCookie | See if a request cookie equals some value. |
existsCookie | See if a request cookie exists. |
header | Get the value of a single request HTTP header. |
headers | Loop through all request headers. |
equalsHeader | See if a request header equals some value. |
existsHeader | See if a request header exists. |
headerValues | Get the name and values of a single header. |
parameter | Get the value of a single request HTTP parameter. |
parameters | Loop through all request parameters. |
equalsParameter | See if a request parameter equals some value. |
existsParameter | See if a request parameter exists. |
parameterValues | Get the name and values of a single parameter. |
queryString | Get the value of a single request HTTP queryString. |
queryStrings | Loop through all request queryStrings. |
existsQueryString | See if a request queryString exists. |
log | Availability: 1.0 | ||||
Log the body of the tag to the servlet context log. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | None | ||||
Variables | None | ||||
Examples | Log the user input parameter. | ||||
|
request | Availability: 1.0 | ||||
Get information about the current request. |
|||||
Tag Body | empty | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
id | Yes | No | 1.0 | ||
Script variable id for use with standard jsp:getProperty tag. |
|||||
Variables | Name | Scope | Availability | ||
id attribute value | Start of tag to end of page | 1.0 | |||
Request Data Bean |
|||||
Properties | Name | Get | Set | Availability | |
authType | Yes | No | 1.0 | ||
Returns the name of the authentication scheme used to protect the page, "BASIC", "SSL," or "" if the page was not protected. |
|||||
contextPath | Yes | No | 1.0 | ||
Returns the portion of the request URI that indicates the context of the request. |
|||||
method | Yes | No | 1.0 | ||
Returns the name of the HTTP method with which this request was made, "GET", "POST", or "PUT". |
|||||
pathInfo | Yes | No | 1.0 | ||
Returns any extra path information associated with the URL the client sent when it made this request. |
|||||
pathTranslated | Yes | No | 1.0 | ||
Returns any extra path information after the servlet name but before the query string, and translates it to a real path. |
|||||
queryString | Yes | No | 1.0 | ||
Returns the query string that is contained in the request URL after the path. |
|||||
remoteUser | Yes | No | 1.0 | ||
Returns the login of the user making this request, if the user has been authenticated, or "" if the user has not been authenticated. |
|||||
requestedSessionId | Yes | No | 1.0 | ||
Returns the session ID specified by the client. |
|||||
requestURI | Yes | No | 1.0 | ||
Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. |
|||||
requestURL | Yes | No | 1.0 | ||
Returns the request URL up to the query string in the first line of the HTTP request. |
|||||
servletPath | Yes | No | 1.0 | ||
Returns the part of this request's URL that calls the servlet. |
|||||
characterEncoding | Yes | No | 1.0 | ||
Returns the name of the character encoding used in the body of this request. |
|||||
contentLength | Yes | No | 1.0 | ||
Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known. |
|||||
contentType | Yes | No | 1.0 | ||
Returns the MIME type of the body of the request, or "" if the type is not known. |
|||||
protocol | Yes | No | 1.0 | ||
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1. |
|||||
remoteAddr | Yes | No | 1.0 | ||
Returns the Internet Protocol (IP) address of the client that sent the request. |
|||||
remoteHost | Yes | No | 1.0 | ||
Returns the fully qualified name of the client that sent the request, or the IP address of the client if the name cannot be determined. |
|||||
scheme | Yes | No | 1.0 | ||
Returns the name of the scheme used to make this request, for example, http, https, or ftp. |
|||||
serverName | Yes | No | 1.0 | ||
Returns the host name of the server that received the request. |
|||||
serverPort | Yes | No | 1.0 | ||
Returns the port number on which this request was received. |
|||||
Examples | Display the requestURI and QueryString | ||||
|
isSecure | Availability: 1.0 | ||||
Test whether the HTTP connection is secure (using HTTPS). |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
value | No | No | 1.0 | ||
If value is set to false the isSecure tag includes body of tag if session is not secure. Default value is true. |
|||||
Variables | None | ||||
Examples | Display whether the clients session is secure | ||||
|
isSessionFromCookie | Availability: 1.0 | ||||
Test whether the HTTP session was from a cookie. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
value | No | No | 1.0 | ||
If value is set to false the isSessionFromCookie tag includes body of tag if session is not from a cookie. Default value is true. |
|||||
Variables | None | ||||
Examples | Display whether the clients session is from a cookie | ||||
|
isSessionFromUrl | Availability: 1.0 | ||||
Test whether the HTTP session was from URL encoding. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
value | No | No | 1.0 | ||
If value is set to false the isSessionFromUrl tag includes body of tag if session is not from a URL. Default value is true. |
|||||
Variables | None | ||||
Examples | Display whether the clients session is from a URL | ||||
|
isSessionValid | Availability: 1.0 | ||||
Test whether the HTTP session is valid. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
value | No | No | 1.0 | ||
If value is set to false the isSessionValid tag includes body of tag if session is not valid. Default value is true. |
|||||
Variables | None | ||||
Examples | Display whether the clients session is valid | ||||
|
isUserInRole | Availability: 1.0 | ||||
Test whether the remote user is in a role. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
role | Yes | No | 1.0 | ||
Name of role to test remote user with. |
|||||
value | No | No | 1.0 | ||
If value is set to false the isUserInRole tag includes body of tag if user is not in role. Default value is true. |
|||||
Variables | None | ||||
Examples | Display whether the remote user is in role "admin" | ||||
|
attribute | Availability: 1.0 | ||||
Get the value of a single request attribute. |
|||||
Tag Body | empty | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of request attribute to get. |
|||||
Variables | None | ||||
Examples | Output the value of the request attribute with name "test1" | ||||
|
attributes | Availability: 1.0 | ||||
Loop through all request attributes. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
id | Yes | No | 1.0 | ||
Script variable id for use with standard jsp:getProperty tag. |
|||||
Variables | Name | Scope | Availability | ||
id attribute value | Nested within tag | 1.0 | |||
Request Attribute Bean |
|||||
Properties | Name | Get | Set | Availability | |
name | Yes | No | 1.0 | ||
Request attribute name. |
|||||
value | Yes | No | 1.0 | ||
Request attribute value. |
|||||
Examples | Output the name and value of all the request attributes | ||||
|
equalsAttribute | Availability: 1.0 | ||||
Includes the body of the tag if the request attribute value equals the match attribute. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of request attribute. |
|||||
value | No | No | 1.0 | ||
If value is set to false the equalsAttribute tag includes body of tag if request attribute does not equal the match attribute. Default is true. |
|||||
match | Yes | No | 1.0 | ||
String to test for equality with request attribute value. |
|||||
ignoreCase | No | No | 1.0 | ||
Set to true to test for equality while ignoring the case of the letters. Set to false to test for case sensitive equality. Default is false |
|||||
Variables | None | ||||
Examples | Determine if the request attribute "test1" value equals "blah" | ||||
|
existsAttribute | Availability: 1.0 | ||||
Includes the body of the tag if the request attribute exists. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of request attribute. |
|||||
value | No | No | 1.0 | ||
If value is set to false the existsAttribute tag includes body of tag if request attribute does not exist. Default is true. |
|||||
Variables | None | ||||
Examples | Determine if the "test1" Request attribute exists | ||||
|
removeAttribute | Availability: 1.0 | ||||
Removes an attribute from a request. |
|||||
Tag Body | empty | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of request attribute to remove. |
|||||
Variables | None | ||||
Examples | Remove the request attribute with name "test1" | ||||
|
setAttribute | Availability: 1.0 | ||||
Sets the value of the request attribute to the content of the tag body. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of request attribute to set value for. |
|||||
Variables | None | ||||
Examples | Set the request attribute with name "test1" | ||||
|
cookie | Availability: 1.0 | ||||
Get the value of a single request cookie. |
|||||
Tag Body | empty | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of request cookie to get. |
|||||
Variables | None | ||||
Examples | Output the value of the request cookie with name "test1" | ||||
|
cookies | Availability: 1.0 | ||||
Loop through all request cookies, or get the properties of a single cookie. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
id | Yes | No | 1.0 | ||
Script variable id for use with standard jsp:getProperty tag. |
|||||
name | No | No | 1.0 | ||
Name of a single cookie to get the properties of. |
|||||
Variables | Name | Scope | Availability | ||
attribute value | Nested within tag | 1.0 | |||
Request Cookie Bean |
|||||
Properties | Name | Get | Set | Availability | |
comment | Yes | No | 1.0 | ||
Cookie comment. |
|||||
domain | Yes | No | 1.0 | ||
Cookie domain. |
|||||
maxAge | Yes | No | 1.0 | ||
Cookie maximum age in seconds, -1 indicates the cookie will persist until client browser shutdown. |
|||||
name | Yes | No | 1.0 | ||
Cookie name. |
|||||
path | Yes | No | 1.0 | ||
Cookie path on server. |
|||||
secure | Yes | No | 1.0 | ||
Returns "1" if the browser is sending cookies only over a secure protocol, or "0" if the browser can send cookies using any protocol. |
|||||
value | Yes | No | 1.0 | ||
Request cookie value. |
|||||
version | Yes | No | 1.0 | ||
Version of the protocol this cookie complies with. |
|||||
Examples | Output the name and value of all the request cookies | ||||
|
|||||
Get the name and value of a single cookie named test1 | |||||
|
equalsCookie | Availability: 1.0 | ||||
Includes the body of the tag if the request cookie value equals the match attribute. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of request cookie. |
|||||
value | No | No | 1.0 | ||
If value is set to false the equalsCookie tag includes body of tag if request cookie does not equal the match attribute. Default is true. |
|||||
match | Yes | No | 1.0 | ||
String to test for equality with request cookie value. |
|||||
ignoreCase | No | No | 1.0 | ||
Set to true to test for equality while ignoring the case of the letters. Set to false to test for case sensitive equality. Default is false |
|||||
Variables | None | ||||
Examples | Determine if the request cookie "test1" value equals "blah" | ||||
|
existsCookie | Availability: 1.0 | ||||
Includes the body of the tag if the request cookie exists. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of request cookie. |
|||||
value | No | No | 1.0 | ||
If value is set to false the existsCookie tag includes body of tag if request cookie does not exist. Default is true. |
|||||
Variables | None | ||||
Examples | Determine if the "test1" Request cookie exists | ||||
|
header | Availability: 1.0 | ||||
Get the value of a single request HTTP header. |
|||||
Tag Body | empty | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of request header to get. |
|||||
Variables | None | ||||
Examples | Output the value of the request header with name "User-Agent" | ||||
|
headers | Availability: 1.0 | ||||
Loop through all request HTTP headers, or get the properties of a single header. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
id | Yes | No | 1.0 | ||
Script variable id for use with standard jsp:getProperty tag. |
|||||
name | No | No | 1.0 | ||
Name of a single header to get the value of. |
|||||
Variables | Name | Scope | Availability | ||
attribute value | Nested within tag | 1.0 | |||
Request Header Bean |
|||||
Properties | Name | Get | Set | Availability | |
name | Yes | No | 1.0 | ||
>Request header name. |
|||||
header | Yes | No | 1.0 | ||
Request header value as a string. |
|||||
dateHeader | Yes | No | 1.0 | ||
Request header value for a date, measured in milliseconds since midnight January 1, 1970 GMT. |
|||||
intHeader | Yes | No | 1.0 | ||
Request header value for an integer. |
|||||
Examples | Output the name and value of all the request headers | ||||
|
|||||
Output the name and value of the User-Agent request header | |||||
|
equalsHeader | Availability: 1.0 | ||||
Includes the body of the tag if the request header value equals the match attribute. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of request header. |
|||||
value | No | No | 1.0 | ||
If value is set to false the equalsHeader tag includes body of tag if request header does not equal the match attribute. Default is true. |
|||||
match | Yes | No | 1.0 | ||
String to test for equality with request header value. |
|||||
ignoreCase | No | No | 1.0 | ||
Set to true to test for equality while ignoring the case of the letters. Set to false to test for case sensitive equality. Default is false |
|||||
Variables | None | ||||
Examples | Determine if the request header "User-Agent" value equals "Netscape" | ||||
|
existsHeader | Availability: 1.0 | ||||
Includes the body of the tag if the request header exists. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of request header. |
|||||
value | No | No | 1.0 | ||
If value is set to false the existsHeader tag includes body of tag if request header does not exist. Default is true. |
|||||
Variables | None | ||||
Examples | Determine if the "User-Agent" Request header exists | ||||
|
headerValues | Availability: 1.0 | ||||
Loop through all the values for an HTTP header which has multiple values. |
|||||
Tag Body | JSP | ||||
Restrictions |
Must be nested inside a headers tag. |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
id | Yes | No | 1.0 | ||
Script variable id for use with standard jsp:getProperty tag. |
|||||
Variables | Name | Scope | Availability | ||
attribute value | Nested within tag | 1.0 | |||
Header Value Bean |
|||||
Properties | Name | Get | Set | Availability | |
header | Yes | No | 1.0 | ||
Request header value as a string. |
|||||
Examples | Output all the values of the HTTP Language header | ||||
|
parameter | Availability: 1.0 | ||||
Get the value of a single request HTTP parameter. |
|||||
Tag Body | empty | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of request parameter to get. |
|||||
Variables | None | ||||
Examples | Output the value of the request parameter with name "test1" | ||||
|
parameters | Availability: 1.0 | ||||
Loop through all request HTTP parameters, or get the properties of a single parameter. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
id | Yes | No | 1.0 | ||
Script variable id for use with standard jsp:getProperty tag. |
|||||
name | No | No | 1.0 | ||
Name of a single parameter to get the value of. |
|||||
Variables | Name | Scope | Availability | ||
id attribute value | Nested within tag | 1.0 | |||
Request Parameter Bean |
|||||
Properties | Name | Get | Set | Availability | |
name | Yes | No | 1.0 | ||
Request parameter name. |
|||||
value | Yes | No | 1.0 | ||
Request parameter value as a string. |
|||||
Examples | Output the name and value of all the request parameters | ||||
|
|||||
Output the name and value of the test1 request parameter | |||||
|
equalsParameter | Availability: 1.0 | ||||
Includes the body of the tag if the request parameter value equals the match attribute. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of request parameter. |
|||||
value | No | No | 1.0 | ||
If value is set to false the equalsParameter tag includes body of tag if request parameter does not equal the match attribute. Default is true. |
|||||
match | Yes | No | 1.0 | ||
String to test for equality with request parameter value. |
|||||
ignoreCase | No | No | 1.0 | ||
Set to true to test for equality while ignoring the case of the letters. Set to false to test for case sensitive equality. Default is false |
|||||
Variables | None | ||||
Examples | Determine if the request parameter "test1" value equals "blah" | ||||
|
existsParameter | Availability: 1.0 | ||||
Includes the body of the tag if the request parameter exists. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of request parameter. |
|||||
value | No | No | 1.0 | ||
If value is set to false the existsParameter tag includes body of tag if request parameter does not exist. Default is true. |
|||||
Variables | None | ||||
Examples | Determine if the "test1" Request parameter exists | ||||
|
parameterValues | Availability: 1.0 | ||||
Loop through all the values for an HTTP parameter which has multiple values. |
|||||
Tag Body | JSP | ||||
Restrictions |
Must be nested inside a parameters tag. |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
id | Yes | No | 1.0 | ||
Script variable id for use with standard jsp:getProperty tag. |
|||||
Variables | Name | Scope | Availability | ||
id attribute value | Nested within tag | 1.0 | |||
Parameter Value Bean |
|||||
Properties | Name | Get | Set | Availability | |
value | Yes | No | 1.0 | ||
Request parameter value as a string. |
|||||
Examples | Output all the values of the HTTP test1 parameter | ||||
|
queryString | Availability: 1.0 | ||||
Get the value of a single request HTTP queryString. |
|||||
Tag Body | empty | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of request queryString to get. |
|||||
Variables | None | ||||
Examples | Output the value of the request queryString with name "test1" | ||||
|
queryStrings | Availability: 1.0 | ||||
Loop through all request HTTP queryStrings, or get the properties of a single queryString. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
id | Yes | No | 1.0 | ||
Script variable id for use with standard jsp:getProperty tag. |
|||||
name | No | No | 1.0 | ||
Name of a single queryString to get the value of. |
|||||
Variables | Name | Scope | Availability | ||
attribute value | Nested within tag | 1.0 | |||
Request QueryString Bean |
|||||
Properties | Name | Get | Set | Availability | |
name | Yes | No | 1.0 | ||
>Request queryString name. |
|||||
queryString | Yes | No | 1.0 | ||
Request queryString value as a string. |
|||||
Examples | Output the name and value of all the request queryStrings | ||||
|
|||||
Output the name and value of the test1 request queryString | |||||
|
existsQueryString | Availability: 1.0 | ||||
Includes the body of the tag if the request queryString exists. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of request queryString. |
|||||
value | No | No | 1.0 | ||
If value is set to false the existsQueryString tag includes body of tag if request queryString does not exist. Default is true. |
|||||
Variables | None | ||||
Examples | Determine if the "test1" Request queryString exists | ||||
|
See the example application request-examples.war for examples of the usage of the tags from this custom tag library.
Java programmers can view the java class documentation for this tag library as javadocs.
Review the complete revision history of this tag library.