Sun Java System Web Server 6.1 SP12 Programmer's Guide to Web Applications

Session Elements

Session elements are as follows:


Note –

The session manager interface is unstable. An unstable interface may be experimental or transitional, and thus may change incompatibly, be removed, or be replaced by a more stable interface in the next release.


session-config

Specifies session configuration information.

Subelements

The following table describes subelements for the session-config element. The left column lists the subelement name, the middle column indicates the requirement rule, and the right column describes what the element does.

Table 6–11 session-config Subelements

Element  

Required  

Description  

session-manager

zero or one 

Specifies session manager configuration information. 

session-properties

zero or one 

Specifies session properties. 

cookie-properties

zero or one 

Specifies session cookie properties. 

Attributes

none

session-manager

Specifies session manager information.


Note –

In Sun Java System Web Server 6.1, you cannot define a session manager either for a single sign-on session or for a virtual server. You must define session managers at the level of web applications.


Subelements

The following table describes subelements for the session-manager element. The left column lists the subelement name, the middle column indicates the requirement rule, and the right column describes what the element does.

Table 6–12 session-manager Subelements

Element  

Required  

Description  

manager-properties

zero or one 

Specifies session manager properties. 

store-properties

zero or one 

Specifies session persistence (storage) properties. 

Attributes

The following table describes attributes for the session-manager element. The left column lists the attribute name, the middle column indicates the default value, and the right column describes what the attribute does.

Table 6–13 session-manager Attributes

Attribute  

Default Value  

Description  

persistence-type

memory

(optional) Specifies the session persistence mechanism. Allowed values are memory, file, s1ws60, and mmap.

Setting the value of persistence type to memory is equivalent to using Sun Java System Web Server’s IWSSessionManager without any store.

Setting the value of persistence type to file is equivalent to using Sun Java System Web Server’s IWSSessionManager with FileStore.

manager-properties

Specifies session manager properties.

Subelements

The following table describes subelements for the manager-properties element. The left column lists the subelement name, the middle column indicates the requirement rule, and the right column describes what the element does.

Table 6–14 manager-properties Subelements

Element  

Required  

Description  

property

zero or more 

Specifies a property, which contains a name and a value. 

Attributes

none

Properties

The following table describes properties for the manager-properties element. The left column lists the property name, the middle column indicates the default value, and the right column describes what the property does.

Table 6–15 manager-properties Properties

Property Name  

Default Value  

Description  

reapIntervalSeconds

60

Specifies the number of seconds between checks for expired sessions. 

Setting this value lower than the frequency at which session data changes is recommended. For example, this value should be as low as possible (1 second) for a hit counter servlet on a frequently accessed web site, or you could lose the last few hits each time you restart the server. 

maxSessions

-1 

Specifies the maximum number of active sessions, or -1 (the default) for no limit.

sessionFilename

none; state is not preserved across restarts 

Specifies the absolute or relative path name of the file in which the session state is preserved between application restarts, if preserving the state is possible. A relative path name is relative to the temporary directory for this web application. 

Applicable only if the persistence-type attribute of the session-manager element is memory.

store-properties

Specifies session persistence (storage) properties.

Subelements

The following table describes subelements for the store-properties element. The left column lists the subelement name, the middle column indicates the requirement rule, and the right column describes what the element does.

Table 6–16 store-properties Subelements

Element  

Required  

Description  

property

zero or more 

Specifies a property, which contains a name and a value. 

Attributes

none

Properties

The following table describes properties for the store-properties element. The left column lists the property name, the middle column indicates the default value, and the right column describes what the property does.

Table 6–17 store-properties Properties

Property Name  

Default Value  

Description  

reapIntervalSeconds

60

Specifies the number of seconds between checks for expired sessions for those sessions that are currently swapped out. 

Setting this value lower than the frequency at which session data changes is recommended. For example, this value should be as low as possible (1 second) for a hit counter servlet on a frequently accessed web site, or you could lose the last few hits each time you restart the server. 

directory

directory specified by javax.servlet.context.tempdir context attribute

Specifies the absolute or relative path name of the directory into which individual session files are written. A relative path is relative to the temporary work directory for this web application. 

session-properties

Specifies session properties.

Subelements

The following table describes subelements for the session-properties element. The left column lists the subelement name, the middle column indicates the requirement rule, and the right column describes what the element does.

Table 6–18 session-properties Subelements

Element  

Required  

Description  

property

zero or more 

Specifies a property, which contains a name and a value. 

Attributes

none

Properties

The following table describes properties for the session-properties element. The left column lists the property name, the middle column indicates the default value, and the right column describes what the property does.

Table 6–19 session-properties Properties

Property Name  

Default Value  

Description  

timeoutSeconds

600

Specifies the default maximum inactive interval (in seconds) for all sessions created in this web application. If set to 0 or less, sessions in this web application do not expire.

If a session-timeout element is specified in the web.xml file, the session-timeout value overrides any timeoutSeconds value. If neither session-timeout nor timeoutSeconds is specified, the timeoutSeconds default is used.

Note that the session-timeout element in web.xml is specified in minutes, not seconds.

enableCookies

true

Uses cookies for session tracking if set to true.

enableURLRewriting

true

Enables URL rewriting. This provides session tracking via URL rewriting when the browser does not accept cookies. You must also use an encodeURL or encodeRedirectURL call in the servlet or JSP.

cookie-properties

Specifies session cookie properties.

Subelements

The following table describes subelements for the cookie-properties element. The left column lists the subelement name, the middle column indicates the requirement rule, and the right column describes what the element does.

Table 6–20 cookie-properties Subelements

Element  

Required  

Description  

property

zero or more 

Specifies a property, which contains a name and a value. 

Attributes

none

Properties

The following table describes properties for the cookie-properties element. The left column lists the property name, the middle column indicates the default value, and the right column describes what the property does.

Table 6–21 cookie-properties Properties

Property Name  

Default Value  

Description  

cookiePath

 

context path at which the web application is installed. 

Specifies the path name that is set when the session tracking cookie is created. The browser sends the cookie if the path name for the request contains this path name. If set to / (slash), the browser sends cookies to all URLs served by the Sun Java System Web Server. You can set the path to a narrower mapping to limit the request URLs to which the browser sends cookies.

cookieMaxAgeSeconds

-1

Specifies the expiration time (in seconds) after which the browser expires the cookie. The default value of -1 indicates that the cookie never expires.

cookieDomain

(unset) 

Specifies the domain for which the cookie is valid. 

cookieComment

Sun Java System Web Server session tracking cookie 

Specifies the comment that identifies the session tracking cookie in the cookie file. Applications can provide a specific comment for the cookie.