The APPLICATION custom tag library contains tags which can be used to access all the information about the ApplicationContext for a JSP application.
Tags are provided to access information in "application" 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/application-1.0</taglib-uri> <taglib-location>/WEB-INF/application.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/application-1.0" prefix="app" %>
where "app" 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 application attribute. |
attributes | Loop through all application attributes. |
equalsAttribute | See if a application attribute equals some value. |
existsAttribute | See if a application attribute exists. |
removeAttribute | Removes an attribute from a application. |
setAttribute | Sets the value of a application attribute. |
initParameter | Get the value of a single application initialization parameter. |
initParameters | Loop through all application initialization parameters. |
equalsInitParameter | See if a application initialization parameter equals some value. |
existsInitParameter | See if an application initialization parameter exists. |
attribute | Availability: 1.0 | ||||
Get the value of a single application attribute. |
|||||
Tag Body | empty | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of application attribute to get. |
|||||
Variables | None | ||||
Examples | Output the value of the application attribute with name "test1" | ||||
|
attributes | Availability: 1.0 | ||||
Loop through all application attributes, or get the value of a single attribute. |
|||||
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.1 | ||
Name of a single attribute to get the value of. |
|||||
Variables | Name | Scope | Availability | ||
id attribute value | Nested within tag | 1.0 | |||
Application Attribute Bean |
|||||
Properties | Name | Get | Set | Availability | |
name | Yes | No | 1.0 | ||
Application attribute name. |
|||||
value | Yes | No | 1.0 | ||
Application attribute value. |
|||||
Examples | Output the name and value of all the application attributes | ||||
|
|||||
Output the name and value of the myatt attribute | |||||
|
equalsAttribute | Availability: 1.0 | ||||
Includes the body of the tag if the application 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 application attribute. |
|||||
value | No | No | 1.0 | ||
If value is set to false the equalsAttribute tag includes body of tag if application attribute does not equal the match attribute. Default is true. |
|||||
match | Yes | No | 1.0 | ||
String to test for equality with application 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 application attribute "test1" value equals "blah" | ||||
|
existsAttribute | Availability: 1.0 | ||||
Includes the body of the tag if the application attribute exists. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of application attribute. |
|||||
value | No | No | 1.0 | ||
If value is set to false the existsAttribute tag includes body of tag if application attribute does not exist. Default is true. |
|||||
Variables | None | ||||
Examples | Determine if the "test1" Application attribute exists | ||||
|
removeAttribute | Availability: 1.0 | ||||
Removes an attribute from a application. |
|||||
Tag Body | empty | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of application attribute to remove. |
|||||
Variables | None | ||||
Examples | Remove the application attribute with name "test1" | ||||
|
setAttribute | Availability: 1.0 | ||||
Sets the value of the application 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 application attribute to set value for. |
|||||
Variables | None | ||||
Examples | Set the application attribute with name "test1" | ||||
|
initParameter | Availability: 1.0 | ||||
Get the value of a single application initialization parameter. |
|||||
Tag Body | empty | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of application initialization parameter to get. |
|||||
Variables | None | ||||
Examples | Output the value of the application initialization parameter with name "test1" | ||||
|
initParameters | Availability: 1.0 | ||||
Loop through all application initialization parameters, or get the value of a single initialization 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 initialization parameter to get the value of. |
|||||
Variables | Name | Scope | Availability | ||
id attribute value | Nested within tag | 1.0 | |||
Application Initialization Parameter Bean |
|||||
Properties | Name | Get | Set | Availability | |
name | Yes | No | 1.0 | ||
Application initialization parameter name. |
|||||
value | Yes | No | 1.0 | ||
Application initialization parameter value as a string. |
|||||
Examples | Output the name and value of all the application initialization parameters | ||||
|
|||||
Output the name and value of the test1 application initialization parameter | |||||
|
equalsInitParameter | Availability: 1.0 | ||||
Includes the body of the tag if the application initialization 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 application initialization parameter. |
|||||
value | No | No | 1.0 | ||
If value is set to false the equalsInitParameter tag includes body of tag if application initParameter does not equal the match attribute. Default is true. |
|||||
match | Yes | No | 1.0 | ||
String to test for equality with application initialization 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 application initialization parameter "test1" value equals "blah" | ||||
|
existsInitParameter | Availability: 1.0 | ||||
Includes the body of the tag if the application initialization parameter exists. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | No | 1.0 | ||
Name of application initialization parameter. |
|||||
value | No | No | 1.0 | ||
If value is set to false the existsInitParameter tag includes body of tag if application initParameter does not exist. Default is true. |
|||||
Variables | None | ||||
Examples | Determine if the "test1" application initialization parameter exists | ||||
|
See the example application application-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.