apollo.Session
Class WebSession

java.lang.Object
  |
  +--apollo.Session.WebSession
All Implemented Interfaces:
java.io.Serializable

public class WebSession
extends java.lang.Object
implements java.io.Serializable

This data will be persistant based on the users Session ID. It's also provides methods for inserting the SessionID in POST and GET actions.

See Also:
Serialized Form

Field Summary
protected  boolean expired
           
protected  java.util.Hashtable sessionData
           
protected  java.lang.String strServletPath
           
 
Constructor Summary
WebSession(java.lang.String username, java.lang.String newSessionID, int i)
          This creates a new Session.
 
Method Summary
 void copy(WebSession otherSession)
          Copies the contents of a different session into this one
 java.util.Enumeration elements()
          This returns an enumeration of the elements stored in the primary session database.
 java.lang.String encodeURL(java.lang.String URL)
          Encodes the supplied URL with the SessionID.
 java.util.Date getCreationDate()
          Returns the Date at which this session was created
 java.lang.String getHidden()
          This will return a HIDDEN field with the session ID embedded in it.
 java.lang.String getServletPath()
          Gets the servlet path for this session
 int getTimeBetweenTransactions()
           
 int getTimeout()
          Returns the current setting for the maximum amount of seconds which may elapse before the session expires itself.
 int getTransactions()
          Returns the number of transactions which have occoured on this object
 java.lang.Object getValue(java.lang.String name)
          Gets a value from the session database.
 boolean hasValue(java.lang.String name)
          Returns true if the session contains that key
 void incTransactions()
          If you have set a Timeout value for your session, you must call either this method or setCurrentTime().
 boolean isExpired()
          This checks to see if the session is expired.
 boolean isNullSession()
          Returns if this session is a special null session
 java.util.Enumeration keys()
          This returns an enumeration of the keys stored in the primary session database.
 void put(java.lang.String name, java.lang.Object value)
          Sets a value in the session database.
 void remove(java.lang.String name)
          Removes a key from the session database.
 void setCurrentTime()
          If you have set a Timeout value for your session, you must call either this method or incTransactions().
 void setExpired(boolean ex)
          This sets this session's status to expired.
 void setIsNullSession(boolean isNullSession)
           
 void setServletPath(java.lang.String strServletPath)
          Stores the servlet path for this session
 void setTimeout(int i)
          This sets the maximum amount of seconds which may elapse before the session expires itself.
 void setValue(java.lang.String name, java.lang.Object value)
          Sets a value in the session database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sessionData

protected java.util.Hashtable sessionData

expired

protected boolean expired

strServletPath

protected java.lang.String strServletPath
Constructor Detail

WebSession

public WebSession(java.lang.String username,
                  java.lang.String newSessionID,
                  int i)
This creates a new Session. If the timeout is less then zero, sessions will not expire based on time.
Parameters:
Username - the Username of the owner of this session
sessionID - the session ID this session should use
timeout - how many seconds between transactions before this session expires. 0 = never
Method Detail

getServletPath

public java.lang.String getServletPath()
Gets the servlet path for this session

setServletPath

public void setServletPath(java.lang.String strServletPath)
Stores the servlet path for this session

copy

public void copy(WebSession otherSession)
Copies the contents of a different session into this one

getCreationDate

public java.util.Date getCreationDate()
Returns the Date at which this session was created
Returns:
The Creation Date

isNullSession

public boolean isNullSession()
Returns if this session is a special null session

setIsNullSession

public void setIsNullSession(boolean isNullSession)

getTimeout

public int getTimeout()
Returns the current setting for the maximum amount of seconds which may elapse before the session expires itself. If this value is 0, the session will not expire itself based on time.
Returns:
The Timeout value for session expiration

setTimeout

public void setTimeout(int i)
This sets the maximum amount of seconds which may elapse before the session expires itself. If this value is 0, the session will not expire itself based on time.

getTransactions

public int getTransactions()
Returns the number of transactions which have occoured on this object
Returns:
The number of transactions which have occoured on this object

setCurrentTime

public void setCurrentTime()
If you have set a Timeout value for your session, you must call either this method or incTransactions(). These methods update the internal counter between transactions to track how much time elapsed.
See Also:
incTransactions()

incTransactions

public void incTransactions()
If you have set a Timeout value for your session, you must call either this method or setCurrentTime(). These methods update the internal counter between transactions to track how much time elapsed. This method also increments the number of transactions which have occoured on this session.
See Also:
setCurrentTime()

keys

public java.util.Enumeration keys()
This returns an enumeration of the keys stored in the primary session database. This does not include special values like transactions, username, Timeout, unless explicitly placed in the table.
Returns:
An Enumeration of the keys stored in this session

elements

public java.util.Enumeration elements()
This returns an enumeration of the elements stored in the primary session database. This does not include special values like transactions, username, Timeout, unless explicitly placed in the table.
Returns:
An Enumeration of the keys stored in this session

setExpired

public void setExpired(boolean ex)
This sets this session's status to expired.
See Also:
expired

isExpired

public boolean isExpired()
This checks to see if the session is expired. It takes into account the session Timeout.
Returns:
The expiration state of this session
See Also:
setExpired(boolean)

getTimeBetweenTransactions

public int getTimeBetweenTransactions()

setValue

public void setValue(java.lang.String name,
                     java.lang.Object value)
Sets a value in the session database.
Parameters:
name - The key/name to be used
value - the value of the object
See Also:
getValue(java.lang.String), remove(java.lang.String), keys()

put

public void put(java.lang.String name,
                java.lang.Object value)
Sets a value in the session database.
Parameters:
name - The key/name to be used
value - the value of the object
See Also:
getValue(java.lang.String), remove(java.lang.String), keys()

getValue

public java.lang.Object getValue(java.lang.String name)
Gets a value from the session database.
Parameters:
name - The key/name to be used for loookup
Returns:
The Object stored under that key/anem value the value of the object
See Also:
setValue(java.lang.String, java.lang.Object), remove(java.lang.String), keys()

hasValue

public boolean hasValue(java.lang.String name)
Returns true if the session contains that key
Parameters:
name - The key/name to be used for loookup
Returns:
True if key exists
See Also:
setValue(java.lang.String, java.lang.Object), remove(java.lang.String), keys()

remove

public void remove(java.lang.String name)
Removes a key from the session database.
Parameters:
name - The key/name to be used
See Also:
getValue(java.lang.String), setValue(java.lang.String, java.lang.Object), keys()

getHidden

public java.lang.String getHidden()
This will return a HIDDEN field with the session ID embedded in it. This should be used for POST forms. It needs to be embedded with EACH post form in the HTML document.
See Also:
encodeURL(java.lang.String)

encodeURL

public java.lang.String encodeURL(java.lang.String URL)
Encodes the supplied URL with the SessionID. This should be used for GET. You should supply the URL of the servlet (normally req.getServletPath()) you may prefix name/value pairs on the URL before and after this command is issued.
Parameters:
URL - The URL to be encoded
See Also:
#printHidden