C H A P T E R  28

HTTP Session Model

An HTTP Session Model uses the HTTP session as its backing data store. HTTP session model fields map directly to HTTP session attributes. Unlike most other models, the fields of an HTTP session model are merely a passthrough vehicle for the values to the session attributes. In other words, setting the value on a field pushes the value immediately into the session attribute without the need to execute the model to update the actual backing data store. This model has no internal storage it is a facade to the session attributes.

HTTP session model is not required for interaction with the HTTP Session within a Sun ONE Application Framework application. The HTTP session API is completely accessible as it is in any web application. This model provides an avenue for the developer to formally declare session attributes during application design time for use in binding and potentially as an adapter or interceptor to HttpSession.

Property Name

Description

Notes

Allow Setting Equivalent Value

In certain application servers, the affect of calling HttpSession.setAttribute() may have consequences, including invoking HttpSessionBindingListeners and or causing transactions on a persistent session store. This property provides a way for redundant setValue() calls to be defensive against passthrough to HttpSession.setAttribute().

 

Name

The class name of the component.

Req


Fields

Property Name

Description

Notes

Attribute Class

Class type of the HTTP session attribute. The HTTP Session Model implementation of setValue() will use this property to coerce value types.

 

Attribute Name

The name of the HTTP session attribute to which the model field maps. This property value may be null (not set) if the developer wishes to rely on the model field name property to also represent the name of the HTTP session attribute. If this property value is set, it must match the exact name intended for the session attribute.

 

Name

The logical name of the model field.

Req

Optional Initial Value

Allows an initial value to encapsulated with the field declaration. In order to have session attributes initialized based on this property, the developer should acquire this model from the ModelManager and invoke the ensureInitialValues() method to push all initial values into HttpSession. The proper place to make this call is from the application servlet onNewSession() method.

 

Store As Transient Attribute

When set to true, calls to setValue() for this field will wrap the actual value in a JavaBean which manages the value as a transient member. The potential value here is when an application server supports the passivation or persistent storage of HttpSession, this property may be used to support an in memory cache of the attribute value. For instance, if developer has a large amount of business data which is needed across a user session, he or she can avoid having this large data structure pushed to disk or persistent store. This is an advanced property which should only be enabled with care. The result of enabling this property is that this session attribute will not be highly available in the case of an application server which provides high availability support for the HTTP session.