NOTE:
The session ID generator, which is used for servlet sessions, employs
cryptographically strong unique random number generation algorithms. This
may present a performance problem on older, slow machines. The Session
Manager API allows you to redefine the random ID generation method and
customize it to your particular needs (see the SimpleSessionManager.java
example file described in "Source Code for SimpleSessionManager").
iPlanet Web Server 4.1 comes with three session managers for creating and managing sessions:
SimpleSessionManager
-- the default session manager when the server runs in single process mode. MMapSessionManager
-- the default session manager when the server runs in multi-process mode.JdbcSessionManager
-- a session manager that stores session information in a database using the JDBC API.SimpleSessionManager
and the session object it manages, SimpleSession
. The source code files for these classes are provided as a starting point for you to define your own session managers if desired. These Java files are in the directory server_root
/plugins/samples/servlets/sessions/SimpleSession
.
The build also includes the source code for JdbcSessionManager
and the session object it manages, JdbcSession
. These Java files are in the directory server_root
/plugins/samples/servlets/sessions/JdbcSession
.
SimpleSessionManager
as the session manager for servlets. If it starts in multi-process mode, it uses MMapSessionManager
. For more information about single process mode versus multi-processes mode, see Chapter 7, "Configuring Server Preferences," in the iPlanet Web Server Administrator's Guide. In addition, you can read about the MaxProcs
parameter in the magnus.conf
file in the NSAPI Programmer's Guide for iPlanet Web Server.
You can change the session manager in any of the following ways:
servlets.sessionmgr
and, if appropriate, also add a line specifying the parameters for the session manager. For example:servlets.sessionmgr=com.netscape.server.http.session.YourSesMgr
servlets.sessionmgr.initArgs=maxSessions=20,timeOut=300,reapInterval=150
context.
context_name
.sessionmgr
and, if appropriate, also add a line specifying the parameters for the session manager. For example:context.global.sessionmgr=com.netscape.server.http.session.YourSesMgrYou can change the global context or define a new context and assign specific servlets to it. For more information, see Appendix C, "Properties Files."
context.global.sessionmgr.initArgs=maxSessions=20,timeOut=300
SimpleSessionManager
works only in single process mode. It is loaded by default if the iPlanet Web Server starts in single-process mode when a SessionManager is not specified in the servlets.properties
or contexts.properties
configuration file. These sessions are not persistent, that is, all sessions are lost when the server is stopped.
SimpleSessionManager
class takes the following parameters:maxSessions
- the maximum number of sessions maintained by the session manager at any given time. The session manager refuses to create any more new sessions if there are already maxSessions
number of sessions present at that time. The default value is 1000.timeOut
- the amount of time in seconds after a session is accessed by the client before the session manager destroys it. Those sessions that haven't been accessed for at least timeOut
seconds are destroyed by the reaper
method. The default value is 1800 (30 minutes).reapInterval
- the amount of time in seconds that the SessionReaper
thread sleeps before calling the reaper
method again. The default value is 600 (10 minutes).SimpleSessionManager
to change its default parameters. You can also enable SimpleSessionManager
for a particular context if the server is running in multi-process mode. To enable the iPlanet Web Server to use SimpleSessionManager
, do any of the following:
com.netscape.server.http.session.SimpleSessionManager
You can also specify parameters for the session manager in the Session Manager Args field, for example:
maxSessions=20,timeOut=300,reapInterval=150
servlets.sessionmgr
and a line specifying the parameters for the session manager:servlets.sessionmgr=com.netscape.server.http.session.SimpleSessionManager
servlets.sessionmgr.initArgs=maxSessions=20,timeOut=300,reapInterval=150
context.
context_name
.sessionmgr
and a line specifying the parameters for the session manager:context.global.sessionmgr=com.netscape.server.http.session.SimpleSessionManager
context.global.sessionmgr.initArgs=maxSessions=20,timeOut=300,reapInterval=150
You can change the global context or define a new context and assign specific servlets to it. For more information, see Appendix C, "Properties Files."
SimpleSessionManager
creates a SimpleSession
object for each session. The source files for SimpleSessionManager.java
and SimpleSession.java
are in the directory server_root
/plugins/samples/servlets/sessions/SimpleSession
.
The source code files for SimpleSessionManager.java
and SimpleSession.java
are provided so you can use them as the starting point for defining your own session managers and session objects. These files are very well commented.
SimpleSessionManager
extends NSHttpSessionManager
. The class file for NSHttpSessionManager
is in the JAR file NSServletLayer.jar
in the directory server_root
/bin/https/jar
. The SimpleSessionManager
implements all the methods in NSHttpSessionManager
that need to be implemented, so you can use SimpleSessionManager
as an example of how to extend NSHttpSessionManager
. When compiling your subclass of SimpleSessionManager
or NSHttpSessionManager
, be sure that the JAR file NSServletLayer.jar
is in your compiler's classpath.
servlets.properties
or contexts.properties
configuration file.
MMapSessionManager
takes the following parameters:maxSessions
- the maximum number of sessions maintained by the session manager at any given time. The session manager refuses to create any more new sessions if there are already maxSessions
number of sessions present at that time. The default value is 1000.maxValuesPerSession
- the maximum number of values or objects a session can hold. There is no limit.maxValuesSize
- the maximum size of each value or object that can be stored in the session. There is no limit.timeOut
- the amount of time in seconds after a session is last accessed by the client before the session manager destroys it. Those sessions that haven't been accessed for at least timeOut
seconds are destroyed by the reaper
method. The default value is 1800 (30 minutes).reapInterval
- the amount of time in seconds that the SessionReaper
thread sleeps before calling the reaper
method again. The default value is 600 (10 minutes).MMapSessionManager
to change its default parameters. You can also enable MMapSessionManager
for a particular context if the server is running in single process mode. To enable iPlanet Web Server to use MMapSessionManager
, do any of the following:
com.netscape.server.http.session.MMapSessionManager
You can also specify parameters for the session manager in the Session Manager Args field, for example:
maxSessions=20,maxValueSize=1024,timeOut=300,reapInterval=150
servlets.sessionmgr
and a line specifying the parameters for the session manager:servlets.sessionmgr=com.netscape.server.http.session.MMapSessionManager
servlets.sessionmgr.initArgs=maxSessions=20,maxValueSize=1024,timeOut=300,reapInterval=150
context.
context_name
.sessionmgr
and a line specifying the parameters for the session manager:context.global.sessionmgr=com.netscape.server.http.session.MMapSessionManager
context.global.sessionmgr.initArgs=maxSessions=20,maxValueSize=1024,timeOut=300,
reapInterval=150
You can change the global context or define a new context and assign specific servlets to it. For more information, see Appendix C, "Properties Files."
This session manager can only store objects that implement java.io.Serializable
.
JdbcSessionManager
has been tested with a standard JDBC-ODBC driver against Microsoft SQL Server 7.0SP1. You must set up the ODBC source, database, and table for the session manager to use. It is recommended that the Session ID column be indexed for higher lookup performance.
JdbcSessionManager
takes the following parameters:provider
- the JDBC driver (the default is sun.jdbc.odbc.JdbcOdbcDriver
). For more information about the JDBC API, see the following web site:http://java.sun.com/products/jdbc/index.html
url
- the data source (the default is jdbc:odbc:LocalServer
).table
- name of the SQL table that store sessions (the default is sessions
).username
- the login username for the database.password
- the login password for the database.reaperActive
- tells the session manager whether to run session reaper to remove expired sessions from the database when true
, which is the default value. It is recommended that only one server in the cluster be running the reaper.accessTimeColumn
- the name of the column that holds the last access time in minutes (the default name is AccessTime
). The SQL type is NUMERIC(9).sessionIdColumn
- the name of the column that holds the session ID (the default name is SessionID
). The SQL type is VARCHAR(100).valueColumn
- the name of the column that holds the session object (the default name is Value
). The SQL type is VARBINARY(4096). This column must be large enough to accommodate all your session data.lookupPool
- the number of connections that perform lookup operations (the default is 4 connections).insertPool
- the number of connections that perform insert operations (the default is 4 connections).updatePool
- the number of connections that perform update operations (the default is 4 connections).deletePool
- the number of connections that perform delete operations (the default is 2 connections).JdbcSessionManager
to change its default parameters. You can also enable JdbcSessionManager
for a particular context if the server is running in single process mode. To enable iPlanet Web Server to use JdbcSessionManager
, do any of the following:
com.netscape.server.http.session.JdbcSessionManager
You can also specify parameters for the session manager in the Session Manager Args field, for example:
timeOut=1200,username=mysession,password=mypassword
servlets.sessionmgr
and a line specifying the parameters for the session manager:servlets.sessionmgr=com.netscape.server.http.session.JdbcSessionManager
servlets.sessionmgr.initArgs=timeOut=1200,username=mysession,password=mypassword
context.
context_name
.sessionmgr
and a line specifying the parameters for the session manager:context.global.sessionmgr=com.netscape.server.http.session.JdbcSessionManager
context.global.sessionmgr.initArgs=timeOut=1200,username=mysession,password=mypassword
You can change the global context or define a new context and assign specific servlets to it. For more information, see Appendix C, "Properties Files."
This session manager can only store objects that implement java.io.Serializable
.
JdbcSessionManager
creates a JdbcSession
object for each session. The source files JdbcSessionManager.java
and JdbcSession.java
are in the directory server_root
/plugins/samples/servlets/sessions/JdbcSession
.
The source code files, JdbcSessionManager.java
and JdbcSession.java
, are provided so you can use them as the starting point for defining your own session managers and session objects. These files are very well commented.
JdbcSessionManager
extends NSHttpSessionManager
. The class file for NSHttpSessionManager
is in the JAR file NSServletLayer.jar
in the directory server_root
/bin/https/jar
. The JdbcSessionManager
implements all the methods in NSHttpSessionManager
that need to be implemented, so you can use JdbcSessionManager
as an example of how to extend NSHttpSessionManager
. When compiling your subclass of JdbcSessionManager
or NSHttpSessionManager
, be sure that the JAR file NSServletLayer.jar
is in your compiler's classpath.
// request is an HttpServletRequest that is passed to the servletThe servlet can call any of the public methods inSessionClass
session = request.getSession(true);
javax.servlet.http.HttpSession
on the session object. These methods include (among others):
getCreationTimeFor more information about the classes
getId
getLastAccessedTime
getMaxInactiveInterval
getValue
HttpServletRequest
and HttpSession
, see Sun Microsystem's API Servlets Documentation at:
http://java.sun.com/products/servlet/2.1/html/api-reference.fm.html
Last Updated: 03/01/00 13:47:14
© Copyright © 2000 Sun Microsystems, Inc. Some preexisting portions Copyright © 2000 Netscape Communications Corp. All rights reserved.
[an error occurred while processing this directive]