Java _ Cao jianbo 11.05

Source: Internet
Author: User


In WEB development, the server can create a session object (session Object) for each user's browser. Note: a browser exclusively occupies a session object (by default ). Therefore, when you need to save user data, the server program can write user data to the session exclusively occupied by the user's browser. When you use the browser to access other programs, other programs can extract the user data from the user's session to serve the user.

The main difference between Session and Cookie is:

Cookie is to write user data to the user's browser.

Session technology writes user data to a session exclusively owned by the user.

The Session object is created by the server. developers can call the getSession method of the request object to obtain the session object.


Session implementation principle


Session processing after IE disables cookies

This experiment demonstrates the problems caused by servlet data sharing after cookies are disabled.

Solution: URL rewriting

Response. encodeRedirectURL (java. lang. String url)

Used to rewrite the url address after the sendRedirect method.

Response. encodeURL (java. lang. String url)

Used to overwrite the url of form actions and hyperlinks


Session failure

Configure the session expiration time in the Web. xml file

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: 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.