Four session tracking technologies of JSP

Source: Internet
Author: User
From: http://blog.sina.com.cn/s/blog_5990faac0100dnfx.html


Cookie

: The name that the server sends to the browser in a Response Header

/
Value Pair. The time when the browser saves
Cookie
To specify the expiration time attribute. When the browser sends
When a request is sent, it checks its saved
Cookie
And contain all
Cookie
. Session tracking

:

In
The browser and the server do not directly transmit all the status information, but only (
Session
ID
). Sent by Browser
Sessionid,
Server
The server tracks all information associated with the session. Transfer
Sessionid
You can use
Cookie
And
URL
Rewrite technology. Most containers support these two technologies. The server cannot tell whether the user has closed the browser.
All session data associated with the previous session is retained on the server until the session times out and the server destroys the session image.
Tracking
The requested session in the same session
ID
There can be multiple methods, mainly including
Cookie
And
URL
Rewrite. URL

Rewrite

: Session
ID
Encoding in
URL
.
Example:
Counter. jjsp; jsessionnid = be8d697876787876befdbde898789098980, even if the browser does not support
Cookie
. For
URL
Secondary write, the server requests
Uri
Extract session
ID
And
The corresponding session is associated, And then when accessing the session data,
JSP
The Processing Method of the page is as follows:
Cookie
Trace session
ID
Method used
Identical. So
Sesssion
Implementation depends on
Cookie
Or
URL
Secondary writing technology. If you want
Cookie
You must use
<C: URL>
Behavior for all
URL
. This means that all pages in the application (at least those pages with references to other pages) must be
JSP
Page.
Page references can be encoded dynamically. If
UR
The Service will lose the session tracking. Hide form fields

: The hidden form field adds the session ID to the hidden form of HTML (type: hidden input ). You can use either of the following methods to call redirection or forwarding.
Page, redirection and forwarding. I)

Forwarding:
<JSP: Forward
Page = "userinfo. jsp"/> forwarding
, JSP
The container uses an internal method to call the target page. The new page continues to process the same request, and the browser does not know that this process involves
And multiple pages. Browser
URL
Will remain unchanged. Ii)

Redirection
: <C: Redirect
Url = "userinfo. jsp"/> Redirection is different from forwarding. When redirecting, the first page notifies the browser to send a new request to the target page. Browse
The
URL
Will become the new page
URL
. Redirection speed is slower than forwarding because the browser must send a new request. At the same time,
New request, so after a redirection, the objects in the request scope will no longer be used.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.