2010-04-14 - Jakarta Taglibs has been retired.

For more information, please explore the Attic.

Jakarta Project: Application Tag Library

Version: 1.0.1

Table of Contents

Overview

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.

Requirements

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 value of the name attribute in jsp:setProperty and jsp:getProperty will refer to an object that is obtained from the applicationContext object through its findAttribute() method.

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.

Configuration

Follow these steps to configure your web application with this tag library:

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.

Tag Summary

Application Attribute Tags
attributeGet the value of a single application attribute.
attributesLoop through all application attributes.
equalsAttribute See if a application attribute equals some value.
existsAttribute See if a application attribute exists.
removeAttributeRemoves an attribute from a application.
setAttributeSets the value of a application attribute.
 
Application Initialization Parameter Tags
initParameter Get the value of a single application initialization parameter.
initParametersLoop through all application initialization parameters.
equalsInitParameter See if a application initialization parameter equals some value.
existsInitParameter See if an application initialization parameter exists.
 

Tag Reference

attribute Availability: 1.0

Get the value of a single application attribute.

Tag Bodyempty    
Restrictions

None

AttributesNameRequired Runtime Expression Evaluation Availability
 name  Yes   No  1.0
 

Name of application attribute to get.

VariablesNone
Examples Output the value of the application attribute with name "test1"  
 



<app:attribute name="test1"/>

          

attributes Availability: 1.0

Loop through all application attributes, or get the value of a single attribute.

Tag BodyJSP    
Restrictions

None

AttributesNameRequired 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.

VariablesNameScopeAvailability
  id attribute value   Nested within tag  1.0
 

Application Attribute Bean

 PropertiesNameGetSetAvailability
   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  
 



<app:attributes id="loop">
Name: <jsp:getProperty name="loop" property="name"/>
Value: <jsp:getProperty name="loop" property="value"/>
</app:attributes>
    
          

Output the name and value of the myatt attribute  
 



<app:attributesid="single" name="myatt">
Name: <jsp:getProperty name="single" property="name"/>
Value: <jsp:getProperty name="single" property="value"/>
</app:attributes>

          

equalsAttribute Availability: 1.0

Includes the body of the tag if the application attribute value equals the match attribute.

Tag BodyJSP    
Restrictions

None

AttributesNameRequired 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

VariablesNone
Examples Determine if the application attribute "test1" value equals "blah"  
 



<app:equalsAttribute name="test1" match="blah">
  The application attribute with name test1 matches the string "blah".
</app:equalsAttribute>
<app:equalsAttribute name="test1" match="blah" value="false">
  The application attribute with name test1 does not match the string "blah".
</app:equalsAttribute>

          

existsAttribute Availability: 1.0

Includes the body of the tag if the application attribute exists.

Tag BodyJSP    
Restrictions

None

AttributesNameRequired 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.

VariablesNone
Examples Determine if the "test1" Application attribute exists  
 



<app:existsAttribute name="test1">
 The application attribute with name test1 exists.
</app:existsAttribute>
<app:existsAttribute name="test1" value="false">
 The application attribute with name test1 does not exist.
</app:existsAttribute>
         
          

removeAttribute Availability: 1.0

Removes an attribute from a application.

Tag Bodyempty    
Restrictions

None

AttributesNameRequired Runtime Expression Evaluation Availability
 name  Yes   No  1.0
 

Name of application attribute to remove.

VariablesNone
Examples Remove the application attribute with name "test1"  
 

   

<app:removeAttribute name="test1"/>

          

setAttribute Availability: 1.0

Sets the value of the application attribute to the content of the tag body.

Tag BodyJSP    
Restrictions

None

AttributesNameRequired Runtime Expression Evaluation Availability
 name  Yes   No  1.0
 

Name of application attribute to set value for.

VariablesNone
Examples Set the application attribute with name "test1"  
 

   

<app:setAttribute name="test1">Test Value</app:setAttribute>
 
          

initParameter Availability: 1.0

Get the value of a single application initialization parameter.

Tag Bodyempty    
Restrictions

None

AttributesNameRequired Runtime Expression Evaluation Availability
 name  Yes   No  1.0
 

Name of application initialization parameter to get.

VariablesNone
Examples Output the value of the application initialization parameter with name "test1"  
 



<app:initParameter name="test1"/>

          

initParameters Availability: 1.0

Loop through all application initialization parameters, or get the value of a single initialization parameter.

Tag BodyJSP    
Restrictions

None

AttributesNameRequired 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.

VariablesNameScopeAvailability
  id attribute value   Nested within tag  1.0
 

Application Initialization Parameter Bean

 PropertiesNameGetSetAvailability
   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  
 



<app:initParameters id="loop">
Name: <jsp:getProperty name="loop" property="name"/>
Value: <jsp:getProperty name="loop" property="value"/>
</app:initParameters>
     
          

Output the name and value of the test1 application initialization parameter  
 



<app:initParameters id="single" name="test1">
Name: <jsp:getProperty name="single" property="name"/>
Value: <jsp:getProperty name="single" property="value"/>
</app:initParameters>
     
          

equalsInitParameter Availability: 1.0

Includes the body of the tag if the application initialization parameter value equals the match attribute.

Tag BodyJSP    
Restrictions

None

AttributesNameRequired 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

VariablesNone
Examples Determine if the application initialization parameter "test1" value equals "blah"  
 



<app:equalsInitParameter name="test1" match="blah">
  The initialization parameter with name test1 matches "blah".
</app:equalsInitParameter>
<app:equalsInitParameter name="test1" match="blah" value="false">
  The initialization parameter with name test1 does not match "blah".
</app:equalsInitParameter>
     
          

existsInitParameter Availability: 1.0

Includes the body of the tag if the application initialization parameter exists.

Tag BodyJSP    
Restrictions

None

AttributesNameRequired 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.

VariablesNone
Examples Determine if the "test1" application initialization parameter exists  
 



<app:existsInitParameter name="test1">
 The initializaion parameter with name test1 exists.
</app:existsInitParameter>
<app:existsInitParameter name="test1" value="false">
 The initialization parameter with name test1 does not exist.
</app:existsInitParameter>
     
          

Examples

See the example application application-examples.war for examples of the usage of the tags from this custom tag library.

Java Docs

Java programmers can view the java class documentation for this tag library as javadocs.

Revision History

Review the complete revision history of this tag library.