Web apps constantly create new sessions

Source: Internet
Author: User
Tags session id

Today, colleagues in the local construction of the Web application development environment, the login has been reported null pointer exception. After viewing the log, it was found that the null value was obtained when reading the properties in the session. After reviewing the code, no exceptions were found. Some places use the Response.Redirect () method, but do not get the value in the session. This article will record how the issue is resolved.

First, the development environment: WebLogic, MyEclipse.

Second, the problem-solving ideas:

1, the confirmation is not because of the code causes, I suspect is the session re-creation reason. To verify this conclusion, I printed the value of the session ID to the console in the code. The location is two places: one is when the login information is placed in the session, one is to visit the session in the login information. After viewing the output information, it was found that the two IDs were completely different, indicating that the session was recreated.

2, the session is constantly re-created, according to the principle of the session, you can know that the server did not get valid Jsessionid information from the request header. So consider disabling cookies locally, and confirm that cookies are not disabled locally. Blocked

3, the suspect session was invalidated. Created a session of the listener class, did not find the session failure action.

4, later view the WebLogic configuration file, found that the cookie path is set:

<weblogic-web-app>    <session-descriptor>        <session-param>            <param-name> cookiepath</param-name>            <param-name>/cw/</param-name>        </session-param>    </session-descriptor></weblogic-web-app>

Change the path to/cw/because there is no local directory, so the cookie file is not created at all. Therefore, after the login information is placed in the session, Jsessionid should be placed in the cookie for the next use, but because the path cannot be found, causing the cookie file is not created correctly, and, after redirection, the request also cannot find the cookie file, Therefore, there is no jsessionid information, so the server can not find any session information from the request, only re-create a session. This causes the problem to be mentioned at the beginning of this article.


This problem can be analogous to other web containers, such as Tomcat.

Web apps constantly create new sessions

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.