Previous Next Contents Index


DefaultHttpSession class

The DefaultHttpSession class is a proxy class for a javax.servlet.http.HttpSession object. When you create subclasses of DefaultHttpSession, these subclasses enable their session objects to conform to the JavaBeans specification (for instance, individual property-getters and property-setters). Both the DefaultHttpSession and user-derived subclasses must have a constructor that takes one argument, the HttpSession.

To retrieve the instance of DefaultHttpSession, you must first ensure that you have correctly configured the SessionInfo section of the application's appInfo.ntv file. In particular, you must set the httpSessionBeanClass attribute to identify the class that acts as proxy for the HttpSession. Assuming that httpSessionBeanClass is set correctly, you can now cast the request to HttpServletRequest2 and call that interface's getHttpSessionBean( ) method.

Note that DefaultHttpSession implements HttpSession. If you want an HttpSession2 object, you must extend the DefaultHttpSession2 class instead.

Although anyone developing a NAS application can use DefaultHttpSession, this class is typically used in components generated by Netscape Application Builder.

Package
com.netscape.server.servlet.extension

Constructor
The following constructor is required:

public DefaultHttpSession(
	HttpSession baseSession)
Use the baseSession parameter to pass in the HttpSession that will serve as the target for all delegated HttpSession methods.

Methods
Most of the methods in the DefaultHttpSession class are delegated from a corresponding method in the HttpSession interface. The following DefaultHttpSession methods are delegated:

For more information on the previous methods, see the interface javax.servlet.http.HttpSession.

DefaultHttpSession contains the following additional methods:

Method
Description
getHttpSession( )
Returns the delegated implementor of the HttpSession methods.
getString( )
Returns a String value from an HttpSession object.
setHttpSession( )
Sets the delegated implementor of all HttpSession methods.

Related Topics
getHttpSessionBean( ) in the HttpServletRequest2 interface,
DefaultHttpSession2 class

getHttpSession( )
Returns the delegated implementor of the HttpSession methods.

Syntax
public HttpSession getHttpSession()
Return Value
An HttpSession object.

Related Topics
setHttpSession( )

getString( )
Returns a String value from an HttpSession object.

Syntax
public String getString(
	String name)

name. The name of the string whose value is to be returned.

Usage
The getString( ) method is almost identical to the getValue( ) method. The only difference is that getValue( ) returns an Object value, whereas getString( ) returns a String value.

Return Value
A String.

Related Topics
getValue( ) method in the HttpSession interface, from the Java Servlet API.

setHttpSession( )
Sets the delegated implementor of all HttpSession methods.

Syntax
public void setHttpSession(
	HttpSession baseSession)

baseSession. The HttpSession object that is delegated as the implementor of all HttpSession methods.

Usage
Use setHttpSession( ) to define the proxy object that implements HttpSession methods. Use getHttpSession( ) to retrieve the object.

Related Topics
getHttpSession( )

 

© Copyright 1999 Netscape Communications Corp.