0% found this document useful (0 votes)
14 views1 page

HttpSession Methods

The document discusses various methods for working with HttpSession in Java web applications. It describes methods such as getAttribute() to retrieve attributes bound to the session, setAttribute() to bind objects to the session, and removeAttribute() to remove attributes. It also covers methods for getting the session ID, checking if the session is new, and getting timestamps for session creation and last access. The invalidate() method is used to invalidate the session and unbind any associated objects.

Uploaded by

KhirulIkwan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views1 page

HttpSession Methods

The document discusses various methods for working with HttpSession in Java web applications. It describes methods such as getAttribute() to retrieve attributes bound to the session, setAttribute() to bind objects to the session, and removeAttribute() to remove attributes. It also covers methods for getting the session ID, checking if the session is new, and getting timestamps for session creation and last access. The invalidate() method is used to invalidate the session and unbind any associated objects.

Uploaded by

KhirulIkwan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

KHIRUL IKWAN BIN IBRAHIM

1118893

WEB PROG 2 SECTION 1

HttpSession Methods

getAttribute Returns the object bound with the specified name in this session, or null if no object is bound under the name. Some other methods to work with Session attributes are, removeAttribute(String name) and setAttribute This method binds an object to this session, using the name specified. removeAttribute This method removes the object bound with the specified name from this session. getAttributename This method returns the object bound with the specified name in this session, or null if no object is bound under the name getId Returns a string containing the unique identifier assigned to this session. public boolean isNew This method returns true if the client does not yet know about the session or if the client chooses not to join the session. getCreationTime Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT. 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. setMaxInactiveInterval Specifies the time, in seconds, between client requests before the servlet container will invalidate this session. We can get session timeout value from getMaxInactiveInterval() method. void invalidate() Invalidates this session then unbinds any objects bound to it.

You might also like