Expresso 5-6

com.jcorporate.expresso.core.jsdkapi
Class GenericSession

java.lang.Object
  extended bycom.jcorporate.expresso.core.jsdkapi.GenericSession

public class GenericSession
extends Object

Different servlet API's have slightly different methods for putting & getting attributes into the session, so we have a method here for cross-API access to the session, and methods that automatically "wrap" string values stored in the session in SerializableString, so the web-apps can be distributed & session shared by appropriate app servers

Author:
Mike Nash

Method Summary
static Object getAttribute(HttpServletRequest req, String code)
          Retrieve any other object
static Enumeration getAttributeNames(HttpServletRequest req)
          Retrieve all attribute names
static String getAttributeString(HttpServletRequest req, String code)
          Return a string stored in the session, unwrapping it from the SerializableString it was stored in
static String getContextPath(HttpServletRequest req)
          Retrieve the context path
static String getId(HttpServletRequest req)
          Retrieve the session id
static void invalidate(HttpServletRequest req)
          Invalidate the session
static void removeAttribute(HttpServletRequest req, String code)
          Remove an attribute from the session
static void setAttribute(HttpServletRequest req, String code, Serializable s)
          Store any Serializable object in the session
static void setAttribute(HttpServletRequest req, String code, String value)
          Store a String (wrapped in a SerializableString) in the session
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setAttribute

public static void setAttribute(HttpServletRequest req,
                                String code,
                                String value)
                         throws ServletException
Store a String (wrapped in a SerializableString) in the session

Parameters:
req - The HttpServletRequest object
code - the attribute code
value - the attribute value
Throws:
ServletException

getAttributeString

public static String getAttributeString(HttpServletRequest req,
                                        String code)
                                 throws ServletException
Return a string stored in the session, unwrapping it from the SerializableString it was stored in

Parameters:
req - the HttpServletRequest
code - the attribute key
Returns:
java.lang.String
Throws:
ServletException - upon error

getAttribute

public static Object getAttribute(HttpServletRequest req,
                                  String code)
                           throws ServletException
Retrieve any other object

Parameters:
req - The servlet request object
code - the attribute key
Returns:
the attribute value object
Throws:
ServletException - upon error

invalidate

public static void invalidate(HttpServletRequest req)
                       throws ServletException
Invalidate the session

Parameters:
req - the servlet request object
Throws:
ServletException - upon error

setAttribute

public static void setAttribute(HttpServletRequest req,
                                String code,
                                Serializable s)
                         throws ServletException
Store any Serializable object in the session

Parameters:
req - the ServletRequest object
code - the attirbute code
s - the serializable value to save to the session
Throws:
ServletException - upon error

removeAttribute

public static void removeAttribute(HttpServletRequest req,
                                   String code)
                            throws ServletException
Remove an attribute from the session

Parameters:
req - the servletrequest object
code - the attribute key
Throws:
ServletException - upon error

getAttributeNames

public static Enumeration getAttributeNames(HttpServletRequest req)
                                     throws ServletException
Retrieve all attribute names

Parameters:
req - the servlet request object
Returns:
an Enumeration of all the names in the session
Throws:
ServletException - upon error

getId

public static String getId(HttpServletRequest req)
                    throws ServletException
Retrieve the session id

Parameters:
req - the servlet request
Returns:
the session id string
Throws:
ServletException - upon error

getContextPath

public static String getContextPath(HttpServletRequest req)
                             throws ServletException
Retrieve the context path

Parameters:
req - the servlet request object
Returns:
the string for the servlet context path
Throws:
ServletException - upon error

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.