The ContextTag class resides in the same package as Context and ContextCache. This class is a simple class that represents a context tag.
A context tag represents the session state for an valid authenticated connection to a backend service. This tag validates that the session is still valid and provides a context for other tags to make requests to that service. At the first request, a connection is made to the backend service using configuration and authentication information. The session service context or state is stored in the session so that the context or state is available across requests.
A context tag does the following:
The service context is retrieved from the session.
If there is no context, a new service context is created and stored into the session.
The service configuration (for example, host, port) and user authentication (for example, credentials) are used to connect to the service.
If a valid session is created, the service context is stored into the session
The ContextTag class defines an abstract findContext method, which finds the context this tag represents:
public abstract Context findContext() throws Exception;
Subclasses must implement this method to return the appropriate context for the session. For an example of this, see Extending the Tag Library.