Questions about J2EE sessions

Source: Internet
Author: User

In the afternoon, my colleague found a problem: After logging on to the same application system and on the same computer with different users, the subsequent users will overwrite the previous user information!

The Code is as follows:

....................................

_ Request. getsessioncontext (). Add ("user", user );

....................................

At first, I did not agree: it should be so! Otherwise, it would be abnormal!

My colleague then asked: What should I do if the customer asks the users later to log on and do not rush out the previous user information?

Two problems arise:

(1) When the previous Code remains unchanged, are you sure that the login user will overwrite the previous Login User information?

(2) What should I do if I don't want to overwrite the previous users?

To prove it rigorously, I decided not to write a small program for testing.

Create a J2EE project with a JSP in it. Use the print session. GETID () method to determine whether the same session is opened twice on the same page!

Unexpectedly, there was a situation where:

(1) If the same browser (Note: ie9 and sogou are not the same browser.), And the sessionids opened twice are the same.

(2) If you useDifferentBrowser (Note: ie9 and sogou are not the same browser.), The sessionid opened twice is different.

With this conclusion, the answer to the question can be solved.

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.