GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||
GeezerVison is showing javaee.github.io — Maintaining Client State
Maintaining Client StateMany applications require that a series of requests from a client be associated with one another. For example, a web application can save the state of a user’s shopping cart across requests. Web-based applications are responsible for maintaining such state, called a session, because HTTP is stateless. To support applications that need to maintain state, Java Servlet technology provides an API for managing sessions and allows several mechanisms for implementing sessions. Accessing a SessionSessions are represented by an Associating Objects with a SessionYou can associate object-valued attributes with a session by name. Such attributes are accessible by any web component that belongs to the same web context and is handling a request that is part of the same session. Recall that your application can notify web context and session listener objects of servlet lifecycle events (Handling Servlet Lifecycle Events). You can also notify objects of certain events related to their association with a session, such as the following.
Session ManagementBecause an HTTP client has no way to signal that it no longer needs a
session, each session has an associated timeout so that its resources
can be reclaimed. The timeout period can be accessed by using a
session’s
To Set the Timeout Period Using NetBeans IDETo set the timeout period in the deployment descriptor using NetBeans IDE, follow these steps.
Session TrackingTo associate a session with a user, a web container can use several methods, all of which involve passing an identifier between the client and the server. The identifier can be maintained on the client as a cookie, or the web component can include the identifier in every URL that is returned to the client. If your application uses session objects, you must ensure that session
tracking is enabled by having the application rewrite URLs whenever the
client turns off cookies. You do this by calling the response’s
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| |||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |