Invalidating a session using session id
The Servlet API provides two methods to perform this encoding: This method encodes (rewrites) the specified URL to include the session ID and returns the new URL, or, if encoding is not needed or not supported, it leaves the URL unchanged.
The rules used to decide when and how to encode a URL are server-specific.
Then the servlet iterates over all the currently valid session IDs, displaying the number of times they have visited this page.
For example, the Java Web Server has the ability to revert to using URL rewriting when cookies fail, and it allows session objects to be written to the server's disk as memory fills up or when the server shuts down.
(The items you place in the session need to implement the interface to take advantage of this option.) See your server's documentation for details pertaining to your server.
To demonstrate these methods, Example 7-5 shows a servlet that manually invalidates a session if it is more than a day old or has been inactive for more than an hour. Behind the scenes, the session ID is usually saved on the client in a cookie or sent as part of a rewritten URL.
All URLs emitted by a servlet should be run through this method.
This method encodes (rewrites) the specified URL to include the session ID and returns the new URL, or, if encoding is not needed or not supported, it leaves the URL unchanged.The Session Tracking API, as we call the portion of the Servlet API devoted to session tracking, should be supported in any web server that supports servlets.The level of support, however, depends on the server.Finally, you can remove an object from a session with if the session being accessed is invalid (we'll discuss invalid sessions in an upcoming section).Example 7-4 shows a simple servlet that uses session tracking to count the number of times a client has accessed it, as shown in Figure 7-2.Note that installing this servlet is a security risk, as it exposes the server's session IDs--these may be used by unscrupulous clients to join other clients' sessions.Tags: Adult Dating, affair dating, sex dating