JSP State Management

Source: Internet
Author: User

no stateful HTTP protocol

Stateless means that when the browser sends a request to the server, the server responds to the client request.

But when the same browser sends the request to the server again, the server does not know that it is just that browser.

Simply put, the server is not going to remember you, so it is a stateless protocol.

two major mechanisms for saving User state (Session/cookie)

What is a cookie?

is a series of text messages that the Web server holds on the client.

Typical application one: Determine whether the registered user has logged on to the website

Typical application two: "Shopping cart" processing

The role of Cookies

Tracking for a specific object

Save user Web browsing history and habits

Simplified Login

Security risk: Easy disclosure of user information

Creation and use of cookies

Create a Cookie Object

Cookie Newcookie = new Cookie (String key, Object value);

Write Cookie Object

Response.addcookie (Newcookie);

Read Cookie Object

cookie[] cookies = request.getcookies ();

Common methods

Session vs. Cookie

JSP State Management

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.