JSP Implicit Objects - PowerPoint PPT Presentation

About This Presentation
Title:

JSP Implicit Objects

Description:

JSP Implicit Objects CS 422 Dick Steflik Implicit Objects Objects created by the servlet container application session request response exception out Config ... – PowerPoint PPT presentation

Number of Views:282
Avg rating:3.0/5.0
Slides: 15
Provided by: DickS157
Category:

less

Transcript and Presenter's Notes

Title: JSP Implicit Objects


1
JSP Implicit Objects
  • CS 422
  • Dick Steflik

2
Implicit Objects
  • Objects created by the servlet container
  • application
  • session
  • request
  • response
  • exception
  • out
  • Config
  • pageContext
  • page

3
Application Object
  • Used to share data between all of the pages that
    make up an application
  • All users share the Application Object
  • Can be accessed from any JSP in the application
    via the ServletContext
  • javax.servlet.http.ServletContext

4
Application Object Methods
  • getAttribute(String name)
  • getAttributeNames
  • setAttribute(String objName, Object object)
  • removeAttribute(String objName)
  • getMajorVersion()
  • getMinorVersion()
  • getServerInfo()
  • getInitParameter(String name)
  • getInitParameterNames
  • getResourceAsStream(Path)
  • log(Message)

5
Sessions
  • A session is a concept that represents a series
    of HTTP requests and responses between a specific
    browser and a specific server.
  • Sessions are managed by the server
  • Created by the server when the first request is
    received from a browser on a new host the server
    starts the session and assigns it an ID.
  • The ID is sent to the browser as a cookie and
    remembered by the server

6
Sessions (more)
  • The server creates a Session object that contains
    the attributes
  • Creation Time
  • ID
  • Last Time Accessed
  • Maximum Inactive Time allowed

7
HTTPSession Interface
  • getAttribute() returns the object associated
    with the specified key string
  • getAttributeNames() returns an enumeration of
    the key strings in the session
  • getCreationTime() returns the time the session
    was created millsecs past midnight since Jan 1,
    1970 GMT
  • getID() returns the session ID as a string
  • getLastAccessedTime() returns thelast time the
    client sent a request for this session
  • getMaxInactiveInterval() returns the maximun
    amount of time that the servlet container between
    client requests before timing out the session
  • setAttribute() associates an object with a key
    string in the session
  • removeAttribute() remove an attribute from the
    session
  • setMaxInactiveInterval() set the time in
    seconds allowed between client requests
  • isNew() true if a new session, false otherwise

8
request Object
  • Javax.servlet. http.httpservletrequest.
  • The object request is of type Javax.servlet.http.h
    ttpservletrequest.
  • This denotes the data included with the HTTP
    Request.
  • The client makes a request that is then passed to
    the server.
  • The requested object is used to take the value
    from clients web browser and pass it to the
    server.
  • This is performed using HTTP request like
    headers, cookies and arguments.

9
response Object
  • Javax.servlet.http.HttpServletResponse
  • The HTTP Response data.
  • The result or the information that fulfills an
    Http request
  • The object response is of type javax.servlet.http.
    gthttpservletresponse. Generally, the object
    response is used with cookies. The response
    object is used to build the HTTP response header

10
pageContext Object
  • Javax.servlet.jsp.pagecontext
  • Used to access page attributes and also to access
    all the namespaces associated with a JSP page.

11
Out Object
  • The Output stream in the context of page.
  • The class or the interface name of the Out object
    is jsp.JspWriter.
  • The Out object is written Javax.servlet.jsp.JspWr
    iter

12
config Object
  • This is used to get information regarding the
    Servlet configuration
  • The class or the interface name of the Config
    object is ServletConfig.
  • The object Config is written Javax.servlet.http.Se
    rvletConfig

13
page Object
  • The Page object denotes the JSP page
  • Used for calling any instance of a Page's
    servlet.
  • The class or the interface name of the Page
    object is jsp.HttpJspPage.
  • The Page object is written Java.lang.Object

14
Passing Values from Page to Page
  • Put values in the session object
  • Put the values in the application object
  • Put values at the end of the URL
Write a Comment
User Comments (0)
About PowerShow.com