Skip to main content

Posts

Showing posts from May, 2015

Change Tomcat JSESSION Cookie Name and Path

Sometime we have a scenario that two different tomcat application running on same domain,  and you want to share a session cookie in between them, there are two problem will come in this scenario i.e: 1. Session Cookie Name : As both the application have same cookie name i.e JSESSIONID , so its difficult to know which JSESSIONID belongs to which application , so in this scenario we need to change the Session cookie name. 2. Cookie Path :  By default tomcat create a session cookie for the app context, due to which we can't share the cookies between two application , so we need to change the cookie path from  context to the root. For doing the above point we can use  ServletContextListener or   web.xml file. 1. ServletContextListener import javax.servlet.SessionCookieConfig; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; public class MyTestListener implements ServletContextListener  {     public void contextInit