Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
289 views
in Technique[技术] by (71.8m points)

java - Changing cookie JSESSIONID name

I have a requirement of having to run multiple tomcat server in single physical box. While accessing these from a browser, when user switches between the applications, it results in logging out the user previously access application. This is because of JSESSIONID cookie conflict.

One possible solution is to run each applications in different context. Unfortunately, my applications will not work in context path setting as none of the resources are accessed with request.getContextPath() prepended in front.

This leaves me to change the name of cookie JSESSIONID to resolve the conflict. Is there a way to do this? If yes, how?

Hope I'm clear in stating my question.

Note: All my application are running in different port in the same machine.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Everything is much simpler with Servlet API 3.0.

Now you can configure it in your web.xml:

<session-config>
    <cookie-config>
        <name>MY_JSESSIONID_YAHOOOOOO</name>
    </cookie-config>
</session-config>

That's it!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...