Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat 7 session cookie path

Tags:

I'm having a huge problem with my application and Tomcat 7. My application needs to set session cookie to "/" path instead of "/context" path. In tomcat 6 it was a matter of adding another property to Connector (emptySessionPath="true") and Tomcat 7 doesn't recognize this thing. I know that Servlet 3.0 spec allows to configure it on per-context basis, but I couldn't make it work with Tomcat 7. It still adds the context path instead of "/".

I will be very grateful for the receipt on how to do it.

like image 432
Juriy Avatar asked Oct 20 '10 16:10

Juriy


People also ask

How does Tomcat define docBase?

The docBase attribute is a path to the WAR file or exploded deployment directory. It is relative to the webapps directory, although an absolute path can be used. The path attribute is the one we are most interested in, as it defines the context path of the application.

What is context path in Tomcat?

The context path refers to the location relative to the server's address which represents the name of the web application. By default, Tomcat derives it from the name of the deployed war-file. So if we deploy a file ExampleApp. war, it will be available at http://localhost:8080/ExampleApp.

Where is context XML in Tomcat?

Individual XML files located in $CATALINA_HOME/conf/[enginename]/[hostname]/ The name of each individual XML file will define a new context path.

What is Jsessionid in Java?

JSESSIONID is a cookie in J2EE web application which is used in session tracking. Since HTTP is a stateless protocol, we need to use any session to remember state. JSESSIONID cookie is created by web container and send along with response to client.


1 Answers

Juts put the sessionCookiePath="/" attribute into your context.xml root node:

<Context ... sessionCookiePath="/" > ... </Context>

like image 194
Vadim Avatar answered Sep 22 '22 01:09

Vadim