The JMS custom tag library contains tags which can be used to perform a variety of JMS related operations such as sending and receiving messages from inside JSP.
Please refer to the detailed overview for more details.
This taglib is currently built on top of the Messenger component from Jakarta Commons. In addition a JMS implementation is required along with 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/jms-1.0</taglib-uri> <taglib-location>/WEB-INF/jms.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/jms-1.0" prefix="jms" %>
where "jms" is the tag name prefix you wish to use for tags from this library. You can change this value to any prefix you like.
connection | Defines a JMS connection facade (Messenger instance) to be used by other JMS tags. |
send | Sends a JMS message to some destination. The message and destination can be specified via attributes or via child tags as shown in the examples below. |
receive | Receives a JMS message from a given destination blocking either forever or for a given timeout value until a message is received. The destination can be specified via an attribute or via a nested <jms:destination> tag as shown in the examples below. |
destination | Defines a JMS Destination to be used by other tags. The name of the destination can either be specified using the 'name' attribute or the body content will be taken as being the destination name. |
message | Creates a JMS Message. |
mapMessage | Creates a JMS MapMessage. This tag may contain other <jms:mapEntry> tags or the body may be specified via the 'map' attribute. |
objectMessage | Creates a JMS ObjectMessage. |
textMessage | Creates a JMS TextMessage. The text body of the message can be specified via the 'body' attribute or via the content of this tag. |
property | Defines a JMS header property which is added to the outer <jms:message> tag. The value of the header can be specified via the value attribute otherwise the tags body is used as the value. |
mapEntry | Defines an entry in a JMS MapMessage. |
connection | Availability: | ||||
Defines a JMS connection facade (Messenger instance) to be used by other JMS tags. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | Yes | |||
The name of the Messenger connection to use |
|||||
var | No | Yes | |||
The JSP attribute variable that the JMS connection will be output as |
|||||
Variables | None | ||||
|
send | Availability: | ||||
Sends a JMS message to some destination. The message and destination can be specified via attributes or via child tags as shown in the examples below. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
connection | No | Yes | |||
The JMS connection facade (Messenger instance). |
|||||
destination | No | Yes | |||
The JMS Destination to send the message to |
|||||
message | No | Yes | |||
The JMS Message to send |
|||||
Variables | None | ||||
|
receive | Availability: | ||||
Receives a JMS message from a given destination blocking either forever or for a given timeout value until a message is received. The destination can be specified via an attribute or via a nested <jms:destination> tag as shown in the examples below. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
var | Yes | Yes | |||
The name of the JSP scope attribute variable which gets defined for the received message |
|||||
connection | No | Yes | |||
The JMS connection facade (Messenger instance). |
|||||
destination | No | Yes | |||
Defines the JMS Destination to use |
|||||
timeout | No | Yes | |||
An optional timeout value in milliseconds for which this tag will wait for a message. This timeout value should be greater than or equal to zero. If no timeout value is specified then the tag to wait indefinitely until a message arrives. If a timeout value is specified and no message arrives before the timeout period expires then a null message is returned. A value of 0 will cause the tag to return immedately (it is equivalent to the receiveNoWait() method in JMS and Messenger). |
|||||
Variables | None | ||||
|
destination | Availability: | ||||
Defines a JMS Destination to be used by other tags. The name of the destination can either be specified using the 'name' attribute or the body content will be taken as being the destination name. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | No | Yes | |||
The name of the Destination connection to use, otherwise the body content of this tag will be used. |
|||||
var | No | Yes | |||
The JSP attribute variable that the JMS Destination will be output as |
|||||
Variables | None | ||||
|
message | Availability: | ||||
Creates a JMS Message. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
var | No | Yes | |||
The name of the JSP attribute variable that the message will be exported as. |
|||||
connection | No | Yes | |||
The JMS connection facade (Messenger instance). |
|||||
correlationID | No | Yes | |||
The JMS Correlation ID that is to be associated with this message |
|||||
replyTo | No | Yes | |||
The JMS Destination that should be used for replies to this message |
|||||
type | No | Yes | |||
The type of the JMS message. A JMS message can be given a type name to use which maybe used by the JMS provider to implement a message type repository. |
|||||
Variables | None | ||||
|
mapMessage | Availability: | ||||
Creates a JMS MapMessage. This tag may contain other <jms:mapEntry> tags or the body may be specified via the 'map' attribute. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
var | No | Yes | |||
The name of the JSP attribute variable that the message will be exported as. |
|||||
connection | No | Yes | |||
The JMS connection facade (Messenger instance). |
|||||
correlationID | No | Yes | |||
The JMS Correlation ID that is to be associated with this message |
|||||
replyTo | No | Yes | |||
The JMS Destination that should be used for replies to this message |
|||||
type | No | Yes | |||
The type of the JMS message. A JMS message can be given a type name to use which maybe used by the JMS provider to implement a message type repository. |
|||||
map | No | Yes | |||
Specifies a Map of String keys and primitive values to be used as the body of the message. |
|||||
Variables | None | ||||
|
objectMessage | Availability: | ||||
Creates a JMS ObjectMessage. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
var | No | Yes | |||
The name of the JSP attribute variable that the message will be exported as. |
|||||
connection | No | Yes | |||
The JMS connection facade (Messenger instance). |
|||||
correlationID | No | Yes | |||
The JMS Correlation ID that is to be associated with this message |
|||||
replyTo | No | Yes | |||
The JMS Destination that should be used for replies to this message |
|||||
type | No | Yes | |||
The type of the JMS message. A JMS message can be given a type name to use which maybe used by the JMS provider to implement a message type repository. |
|||||
body | No | Yes | |||
The Serializable object used as the body of this JMS ObjectMessage. |
|||||
Variables | None | ||||
|
textMessage | Availability: | ||||
Creates a JMS TextMessage. The text body of the message can be specified via the 'body' attribute or via the content of this tag. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
var | No | Yes | |||
The name of the JSP attribute variable that the message will be exported as. |
|||||
connection | No | Yes | |||
The JMS connection facade (Messenger instance). |
|||||
correlationID | No | Yes | |||
The JMS Correlation ID that is to be associated with this message |
|||||
replyTo | No | Yes | |||
The JMS Destination that should be used for replies to this message |
|||||
type | No | Yes | |||
The type of the JMS message. A JMS message can be given a type name to use which maybe used by the JMS provider to implement a message type repository. |
|||||
body | No | Yes | |||
The String used as the body of this JMS TextMessage. |
|||||
Variables | None | ||||
|
property | Availability: | ||||
Defines a JMS header property which is added to the outer <jms:message> tag. The value of the header can be specified via the value attribute otherwise the tags body is used as the value. |
|||||
Tag Body | JSP | ||||
Restrictions |
None |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | Yes | |||
Defines the name of the header to set. |
|||||
value | No | Yes | |||
Defines the value of the header. If this attribute is not specified then the body of this tag is used instead. |
|||||
Variables | None | ||||
|
mapEntry | Availability: | ||||
Defines an entry in a JMS MapMessage. |
|||||
Tag Body | JSP | ||||
Restrictions |
Should only be used within a <jms:mapMessage> tag |
||||
Attributes | Name | Required | Runtime Expression Evaluation | Availability | |
name | Yes | Yes | |||
Defines the name of the entry. |
|||||
value | No | Yes | |||
Defines the value of the entry. If this attribute is not specified then the body of this tag is used instead. |
|||||
Variables | None | ||||
|
See the example application jms-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.