Previous Next Contents Index


DefaultHttpSession2 class

The DefaultHttpSession2 class is a proxy class for an HttpSession2 object. HttpSession2 is an interface of the NAS API, in the package com.netscape.server.servlet.extension.

When you create subclasses of DefaultHttpSession2, these subclasses enable their session objects to conform to the JavaBeans specification (for instance, individual property-getters and property-setters). Both the DefaultHttpSession2 and user-derived subclasses must have a constructor that takes one argument, the HttpSession. This HttpSession must also be an HttpSession2 object.

In other words, the application must use NAS sessions that implement both HttpSession and HttpSession2. To configure applications to use NAS sessions, set the appropriate session property in the appInfo.ntv file.

To retrieve the instance of DefaultHttpSession2, 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 HttpSession2. Assuming that httpSessionBeanClass is set correctly, you can now cast the request to HttpServletRequest2 and call that interface's getHttpSessionBean( ) method.

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

Although anyone developing a NAS application can use DefaultHttpSession2, 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 DefaultHttpSession2(
	HttpSession baseSession)
Use the baseSession parameter to pass in the Object that will serve as the target for all delegated HttpSession2 and HttpSession methods.

Methods
Most of the methods in the DefaultHttpSession2 class are delegated from a corresponding method in the interface com.netscape.server.servlet.extension.HttpSession2. The following DefaultHttpSession2 methods are delegated:

For more information on the previous methods, see the HttpSession2 interface in this guide.

DefaultHttpSession2 contains the following additional methods:

Method
Description
getHttpSession2( )
Returns the delegated implementor of the HttpSession2 methods.
invalidate( )
Overrides the invalidate( ) method of DefaultHttpSession to clear out the pointer to the session delegate.
setHttpSession2( )
Sets the delegated implementor of all HttpSession2 methods.

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

getHttpSession2( )
Returns the delegated implementor of the HttpSession2 methods.

Syntax
public HttpSession2 getHttpSession2()
Return Value
An HttpSession2 object.

Related Topics
setHttpSession2( )

invalidate( )
Overrides the invalidate( ) method of DefaultHttpSession to clear out the pointer to the session delegate.

Syntax
public void invalidate()
Usage
The invalidate( ) method overrides the DefaultHttpSession invalidate( ) method, which in turn is a delegated HttpSession method. Use invalidate( ) to clear out the pointer to the session delegate.

Related Topics
invalidate( ) method in the javax.servlet.http.HttpSession interface

setHttpSession2( )
Sets the delegated implementor of all HttpSession2 methods.

Syntax
public void setHttpSession2(
	HttpSession2 baseSession2)

baseSession2. The HttpSession2 object that is delegated as the implementor of all HttpSession2 methods.

Usage
Use setHttpSession2( ) to set the HttpSession2 object that acts as the delegated implementor of all HttpSession2 methods. Use getHttpSession2( ) to retrieve the object that was set.

The setHttpSession2( ) method calls setHttpSession( ) if the passed-in baseSession2 parameter is also an HttpSession object.

Related Topics
getHttpSession2( )

 

© Copyright 1999 Netscape Communications Corp.