Top Description Fields Constructors Methods
org.glassfish.grizzly.servlet

public Class HttpSessionImpl

extends Object
implements HttpSession
Class Inheritance
All Implemented Interfaces
jakarta.servlet.http.HttpSession
Static Imports
java.util.concurrent.TimeUnit.MILLISECONDS, .TimeUnit.SECONDS

Basic HttpSession based on Session support.
Author
Jeanfrancois Arcand

Field Summary

Modifier and TypeField and Description
private final WebappContext
contextImpl

The ServletContext.

private static final Logger
private final Session
session

The real session object

Constructor Summary

AccessConstructor and Description
public
HttpSessionImpl(final WebappContext contextImpl, final Session
internal session object
session
)

Create an HttpSession.

Method Summary

Modifier and TypeMethod and Description
protected void
access()

Reset the timestamp.

public Object
getAttribute(String key)

Implements jakarta.servlet.http.HttpSession.getAttribute.

Returns the object bound with the specified name in this session, or null if no object is bound under the name.

public Enumeration<String>
getAttributeNames()

Implements jakarta.servlet.http.HttpSession.getAttributeNames.

Returns an Enumeration of String objects containing the names of all the objects bound to this session.

public long
getCreationTime()

Implements jakarta.servlet.http.HttpSession.getCreationTime.

Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.

public String
getId()

Implements jakarta.servlet.http.HttpSession.getId.

Returns a string containing the unique identifier assigned to this session.

public long
getLastAccessedTime()

Implements jakarta.servlet.http.HttpSession.getLastAccessedTime.

Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight January 1, 1970 GMT, and marked by the time the container received the request.

public int
getMaxInactiveInterval()

Implements jakarta.servlet.http.HttpSession.getMaxInactiveInterval.

Returns the maximum time interval, in seconds, that the servlet container will keep this session open between client accesses.

public ServletContext
getServletContext()

Implements jakarta.servlet.http.HttpSession.getServletContext.

Returns the ServletContext to which this session belongs.

public synchronized void
invalidate()

Implements jakarta.servlet.http.HttpSession.invalidate.

Invalidates this session then unbinds any objects bound to it.

public boolean
isNew()

Implements jakarta.servlet.http.HttpSession.isNew.

Returns true if the client does not yet know about the session or if the client chooses not to join the session.

protected boolean

Returns:

true if valid.
isValid
()

Is the current Session valid?

protected void
notifyIdChanged(final String oldId)

Invoke to notify all registered HttpSessionListener of the session has just been created.

protected void
notifyNew()

Invoke to notify all registered HttpSessionListener of the session has just been created.

public void
removeAttribute(String key)

Implements jakarta.servlet.http.HttpSession.removeAttribute.

Removes the object bound with the specified name from this session.

public void
setAttribute(String key, Object value)

Implements jakarta.servlet.http.HttpSession.setAttribute.

Binds an object to this session, using the name specified.

public void
setMaxInactiveInterval(int sessionTimeout)

Implements jakarta.servlet.http.HttpSession.setMaxInactiveInterval.

Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextImplback to summary
private final WebappContext contextImpl

The ServletContext.

LOGGERback to summary
private static final Logger LOGGER
sessionback to summary
private final Session session

The real session object

Constructor Detail

HttpSessionImplback to summary
public HttpSessionImpl(final WebappContext contextImpl, final Session session)

Create an HttpSession.

Parameters
session:Session

internal session object

Method Detail

accessback to summary
protected void access()

Reset the timestamp.

getAttributeback to summary
public Object getAttribute(String key)

Implements jakarta.servlet.http.HttpSession.getAttribute.

Doc from jakarta.servlet.http.HttpSession.getAttribute.

Returns the object bound with the specified name in this session, or null if no object is bound under the name.

Annotations
@Override
getAttributeNamesback to summary
public Enumeration<String> getAttributeNames()

Implements jakarta.servlet.http.HttpSession.getAttributeNames.

Doc from jakarta.servlet.http.HttpSession.getAttributeNames.

Returns an Enumeration of String objects containing the names of all the objects bound to this session.

Annotations
@Override
getCreationTimeback to summary
public long getCreationTime()

Implements jakarta.servlet.http.HttpSession.getCreationTime.

Doc from jakarta.servlet.http.HttpSession.getCreationTime.

Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.

Annotations
@Override
getIdback to summary
public String getId()

Implements jakarta.servlet.http.HttpSession.getId.

Doc from jakarta.servlet.http.HttpSession.getId.

Returns a string containing the unique identifier assigned to this session. The identifier is assigned by the servlet container and is implementation dependent.

Annotations
@Override
getLastAccessedTimeback to summary
public long getLastAccessedTime()

Implements jakarta.servlet.http.HttpSession.getLastAccessedTime.

Doc from jakarta.servlet.http.HttpSession.getLastAccessedTime.

Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight January 1, 1970 GMT, and marked by the time the container received the request.

Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time.

Annotations
@Override
getMaxInactiveIntervalback to summary
public int getMaxInactiveInterval()

Implements jakarta.servlet.http.HttpSession.getMaxInactiveInterval.

Doc from jakarta.servlet.http.HttpSession.getMaxInactiveInterval.

Returns the maximum time interval, in seconds, that the servlet container will keep this session open between client accesses. After this interval, the servlet container will invalidate the session. The maximum time interval can be set with the setMaxInactiveInterval method.

A return value of zero or less indicates that the session will never timeout.

Annotations
@Override
getServletContextback to summary
public ServletContext getServletContext()

Implements jakarta.servlet.http.HttpSession.getServletContext.

Doc from jakarta.servlet.http.HttpSession.getServletContext.

Returns the ServletContext to which this session belongs.

Annotations
@Override
invalidateback to summary
public synchronized void invalidate()

Implements jakarta.servlet.http.HttpSession.invalidate.

Doc from jakarta.servlet.http.HttpSession.invalidate.

Invalidates this session then unbinds any objects bound to it.

Annotations
@Override
isNewback to summary
public boolean isNew()

Implements jakarta.servlet.http.HttpSession.isNew.

Doc from jakarta.servlet.http.HttpSession.isNew.

Returns true if the client does not yet know about the session or if the client chooses not to join the session. For example, if the server used only cookie-based sessions, and the client had disabled the use of cookies, then a session would be new on each request.

Annotations
@Override
isValidback to summary
protected boolean isValid()

Is the current Session valid?

Returns:boolean

true if valid.

notifyIdChangedback to summary
protected void notifyIdChanged(final String oldId)

Invoke to notify all registered HttpSessionListener of the session has just been created.

notifyNewback to summary
protected void notifyNew()

Invoke to notify all registered HttpSessionListener of the session has just been created.

removeAttributeback to summary
public void removeAttribute(String key)

Implements jakarta.servlet.http.HttpSession.removeAttribute.

Doc from jakarta.servlet.http.HttpSession.removeAttribute.

Removes the object bound with the specified name from this session. If the session does not have an object bound with the specified name, this method does nothing.

After this method executes, and if the object implements HttpSessionBindingListener, the container calls HttpSessionBindingListener.valueUnbound. The container then notifies any HttpSessionAttributeListeners in the web application.

Annotations
@Override
setAttributeback to summary
public void setAttribute(String key, Object value)

Implements jakarta.servlet.http.HttpSession.setAttribute.

Doc from jakarta.servlet.http.HttpSession.setAttribute.

Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.

After this method executes, and if the new object implements HttpSessionBindingListener, the container calls HttpSessionBindingListener.valueBound. The container then notifies any HttpSessionAttributeListeners in the web application.

If an object was already bound to this session of this name that implements HttpSessionBindingListener, its HttpSessionBindingListener.valueUnbound method is called.

If the value passed in is null, this has the same effect as calling removeAttribute().

Annotations
@Override
setMaxInactiveIntervalback to summary
public void setMaxInactiveInterval(int sessionTimeout)

Implements jakarta.servlet.http.HttpSession.setMaxInactiveInterval.

Doc from jakarta.servlet.http.HttpSession.setMaxInactiveInterval.

Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.

An interval value of zero or less indicates that the session should never timeout.

Annotations
@Override