Methods Supported by the "session" Object
This section describes methods supported by the 'session' implicit object provided by the JSP container.
session: An implicit object provided by the JSP container to hold information and methods
common to all JSP pages running under one session. The session object is an instance
of a class that implements the javax.servlet.http.HttpSession interface defined by the J2EE
Here are some methods provided by the 'session' object:
- getAttribute(): Returns the object that is associated to the specified key string
previously saved in the session.
- getAttributeNames(): Returns an Enumeration object that contains all the key strings
saved in the session.
- getCreationTime(): Returns the time when this session was created, measured
in milliseconds since midnight January 1, 1970 GMT.
- getId(): Returns the session ID as a string.
- setAttribute(): Save an object with the specified key string in the session
so that it can be used by the same or another request later in the same session.
- getServletContext(): Returns the ServletContext to which this session belongs.
- getMaxInactiveInterval(): Returns the maximum time interval, in seconds,
that the servlet container will keep this session open between client accesses.
- invalidate(): Invalidates this session then unbinds any objects bound to it.
More information about the session object and sample JSP codes will be give in another chapter.
Table of Contents
About This Book
JSP (JavaServer Pages) Overview
Tomcat Installation on Windows Systems
JSP Scripting Elements
Java Servlet Introduction
►JSP Implicit Objects
What Are Implicit Objects
Information of JSP Execution Context
Information from "request" Object
►Methods Supported by the "session" Object
Syntax of JSP Pages and JSP Documents
JSP Application Session
Managing Cookies in JSP Pages
JavaBean Objects and "useBean" Action Elements
Managing HTTP Response Header Lines
Non-ASCII Characters Support in JSP Pages
Performance of JSP Pages
EL (Expression Language)
Overview of JSTL (JSP Standard Tag Libraries)
JSTL Core Library
JSP Custom Tags
JSP Java Tag Interface
Custom Tag Attributes
Multiple Tags Working Together
File Upload Test Application
Using Tomcat on CentOS Systems
Using Tomcat on macOS Systems
Connecting to SQL Server from Servlet
Developing Web Applications with Servlet
Full Version in PDF/EPUB