The PAGE custom tag library contains tags which can be used to access all the information about the PageContext for a JSP page.
Tags are provided to access information in "page" scoped attributes.
This custom tag library requires no software other than a servlet container that supports the JavaServer Pages Specification, version 1.1.
The tag library also works in some JSP version 1.1 servlet containers, such as Tomcat, but not in others, such as Weblogic. The tags in this tag library are designed according to the JSP 1.2 specification, which makes this requirement of the <jsp:getProperty ... /> tag:
The JSP 1.1 specification does not require this behaviour, and while Tomcat happens to support it, Weblogic does not. Note that it is fairly straightforward to write a custom tag that emulates this behaviour for Weblogic users. Sample source code for such a tag can be found here.
Follow these steps to configure your web application with this tag library:
<taglib> <taglib-uri>http://jakarta.apache.org/taglibs/page-1.0</taglib-uri> <taglib-location>/WEB-INF/page.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/page-1.0" prefix="page" %>
where "page" is the tag name prefix you wish to use for tags from this library. You can change this value to any prefix you like.
attribute | Get the value of a single page attribute. |
attributes | Loop through all page attributes. |
equalsAttribute | See if a page attribute equals some value. |
existsAttribute | See if a page attribute exists. |
removeAttribute | Removes an attribute from a page. |
setAttribute | Sets the value of a page attribute. |
attribute | Availability: 1.0 | ||||
Get the value of a single page attribute. |
|||||
Tag Body | empty | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of page attribute to get. |
|||||
Variables | None | ||||
Examples | Output the value of the page attribute with name "test1" | ||||
|
attributes | Availability: 1.0 | ||||
Loop through all page 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 | |||
Page Attribute Bean |
|||||
Properties | Name | Get | Set | Availability | |
name | Yes | No | 1.0 | ||
Page attribute name. |
|||||
value | Yes | No | 1.0 | ||
Page attribute value. |
|||||
Examples | Output the name and value of all the page attributes | ||||
|
equalsAttribute | Availability: 1.0 | ||||
Includes the body of the tag if the page 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 page attribute. |
|||||
value | No | No | 1.0 | ||
If value is set to false the equalsAttribute tag includes body of tag if page attribute does not equal the match attribute. Default is true. |
|||||
match | Yes | No | 1.0 | ||
String to test for equality with page 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 page attribute "test1" value equals "blah" | ||||
|
existsAttribute | Availability: 1.0 | ||||
Includes the body of the tag if the page attribute exists. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of page attribute. |
|||||
value | No | No | 1.0 | ||
If value is set to false the existsAttribute tag includes body of tag if page attribute does not exist. Default is true. |
|||||
Variables | None | ||||
Examples | Determine if the "test1" Page attribute exists | ||||
|
removeAttribute | Availability: 1.0 | ||||
Removes an attribute from a page. |
|||||
Tag Body | empty | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of page attribute to remove. |
|||||
Variables | None | ||||
Examples | Remove the page attribute with name "test1" | ||||
|
setAttribute | Availability: 1.0 | ||||
Sets the value of the page 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 page attribute to set value for. |
|||||
Variables | None | ||||
Examples | Set the page attribute with name "test1" | ||||
|
See the example application page-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.