Sun Java System Portal Server 7.1 Technical Reference

Tag Attributes, Return Values, and Exceptions


You can pass two kinds of attributes to the Desktop library tags:


The simplest way to pass in an attribute is to specify it as a string, for example:

<dt:sometag attribute1="myAttribute"/>

The string myAttribute becomes the value of attribute1. If a tag expects an integer attribute, use the following:

<dt:sometag attribute1="12345"/>

The tag uses the corresponding Java classes (java.lang.Integer) to translate the string to an integer value. The same applies to all the primitive Java types (boolean, int, and so on).


Sometimes you cannot pass in an attribute as a string. For example, it is impossible to specify a provider object as a string. In this case, the attribute needs to be passed in as a reference defined in the pageContext. You do so by concatenating the character $ with the name of the object stored in the pageContext, for example:

<dt:sometag attribute1="$myAttribute"/>

In this example, the value of attribute1 is whatever object is stored in the pageContext. The method pageContext.findAttribute() is used, not getAttribute(). So it is possible to define some value in the request object and pass this object in as a reference.

Note –

This mechanism is the main form of communication between tags in the Desktop tag library as well as other tags in other tag libraries (for example, jsptl).

Return Values

Tags with attributes id and scope (even if they are optional) are expected to return a value as a result of using the tags. Values can be “returned” in two ways:

Print to the JspWriter stream

If the attribute id is not given when using a tag, the tag prints the value to the JspWriter stream. This results in the value showing up in the HTML code generated by the JSPs. In this case, the attribute scope is ignored.

Store the value in pageContext

If you specify the attribute id when using a tag, the tag stores the value to the pageContext as an attribute with a name specified by the id attribute. This operation overwrites whatever original value the attribute has. In addition to the id, you can also define the attribute scope. It can have one of the following values: page, request, session, or application. These values correspond to the PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, and APPLICATION_SCOPE defined in javax.servlet.jsp.PageContext. This specifies the scope in which to save the value. If no or unrecognized scope is given, the default is to save it in page scope.


The tag library provides five types of exceptions.

Invalid Tag Sequence

Occurs when obtain tags are nested in an invalid sequence. See Using the Desktop Tag Library in Your Application for the sequencing of the obtain tags. The name of the first tag that violates the sequence is provided.

Invalid Provider Type

Occurs when a validation test is not passed. That is, the TLD does not support the current provider in the context. The name of the validator tag that failed is provided.

Invalid Parameter

Occurs when an attribute passed in with the tag is not a legal parameter for the tag. The name of the attribute that causes the problem is provided.

Undefined Parameter

Occurs when an attribute is passed in as reference, but the attribute is not defined in the page context. The name of the attribute is provided.

Empty Context

Occurs when there is no container or provider in the context to operate on. Most likely, the appropriate obtain tag is missing so the context is not set up properly.

The many of the Java classes that support these tags reside in a JAR file desktoptl.jar in the Web-Container-Instance/portal/web-apps/WEB-INF/lib directory. The classes for the jx.tld and jr.tld tags reside in the jsptl.jar file.