Sun Java System Web Server 7.0 Update 3 Developer's Guide to Java Web Applications

Session Elements

Session elements are as follows:


Note –

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


session-config Element

This element specifies session configuration information.

Subelements

The following table describes subelements for the session-config element.

Table A–9 session-config Subelements

Element 

Required 

Description 

session-manager Element

zero or one 

Specifies session manager configuration information 

session-properties Element

zero or one 

Specifies session properties 

cookie-properties Element

zero or one 

Specifies session cookie properties 

Attributes

none

session-manager Element

Specifies session manager information.


Note –

As of Web Server, 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.

Table A–10 session-manager Subelements

Element 

Required 

Description 

manager-properties Element

zero or one 

Specifies session manager properties. 

store-properties Element

zero or one 

Specifies session persistence (storage) properties. 

Attribute

The following table describes the persistence-type attribute 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 A–11 session-manager Attribute

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 Web Server’s IWS60 without any store.

Setting the value of persistence type to file is equivalent to using Web Server’s IWS60 with FileStore.

manager-properties Element

This element specifies session manager properties.

Subelement

The following table describes the property subelement for the manager-properties element.

Table A–12 manager-properties Subelements

Element 

Required 

Description 

property Element

zero or more 

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

Attributes

none

Properties

The following table describes properties for the manager-properties element.

Table A–13 manager-properties Properties

Property Name 

Default Value 

Description 

reapIntervalSeconds

60

Specifies the number of seconds between checks for expired sessions. 

Set this value lower than the frequency at which session data changes . 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 element is memory.

store-properties Element

Specifies session persistence (storage) properties.

Subelement

The following table describes the property subelement for the store-properties element.

Table A–14 store-properties Subelement

Element 

Required 

Description 

property Element

zero or more 

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

Attributes

none

Properties

The following table describes properties for the store-properties element.

Table A–15 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. 

Set 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 Element

This element specifies session properties.

Subelements

The following table describes the property subelement for the session-properties element.

Table A–16 session-properties Subelements

Element 

Required 

Description 

property Element

zero or more 

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

Attributes

none

Properties

The following table describes properties for the session-properties element.

Table A–17 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 session expires immediately.

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 Element

This element specifies session cookie properties.

Subelement

The following table describes the property subelement for the cookie-properties element.

Table A–18 cookie-properties Subelement

Element 

Required 

Description 

property Element

zero or more 

Specifies a property, which has a name and a value 

Attributes

none

Properties

The following table describes properties for the cookie-properties element.

Table A–19 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 / (root), the browser sends cookies to all URLs served by the 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 more specific comment for the cookie.