SimpleSessionManager
and the session objects it manages, SimpleSession
. The source code 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
.
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 Enterprise Server 4.0 Administrator's Guide.
You can change the session manager in either 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.YourSessionManager
servlets.sessionmgr.initArgs=maxSessions=20,timeOut=300,reapInterval=150
SimpleSessionManager
works only in single process mode. It is loaded by default if the Enterprise Server starts in single-process mode when a SessionManager is not specified in the servlets.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:
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 will be destroyed by the reaper()
method.reapInterval
- the amount of time in seconds that the SessionReaper thread sleeps before calling the reaper()
method again.SimpleSessionManager
do either of the following:
com.netscape.server.http.session.SimpleSessionManager
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
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 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/plugins/jar
. 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 class path.
servlets.properties
configuration file.
MMapSessionManager
takes the following parameters:
maxValuesPerSession
- maximum number of values a session can hold. maxValuesSize
- maximum size of the object that can be stored in the session. 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 will be destroyed by the reaper()
method.reapInterval
- the amount of time in seconds that the SessionReaper thread sleeps before calling the reaper()
method again.MMapSessionManager
do either of the following:
com.netscape.server.http.session.MMapSessionManager
servlets.sessionmgr
and a line specifying the parameters for the session manager:servlets.sessionmgr=com.netscape.server.http.session.MMapSessionManagerSessionManagerThis session manager can only store objects that implement
servlets.sessionmgr.initArgs=maxSessions=20,maxValueSize=1024,timeOut=300,reapInterval=150
java.io.Serializable
.
// request is an HttpServletRequest that is passed to the servletThe servlet can call any of the public methods in
SessionClasssession = request.getSession(true);
javax.servlet.http.HttpSession
on the session object. These methods include (amongst others):
getCreationTimeFor more information about the classes
getId
getLastAccessedTime
getMaxInactiveInterval
getValue
HttpServletRequest
and HttpSession
, see Sun Microsystem's API Servlets Documentation at:
http://www.javasoft.com/products/servlet/2.1/html/api-reference.fm.html
Last Updated: 08/12/99 12:39:28
Copyright © 1999 Netscape Communications Corp. All rights reserved.