Search code examples
jsptomcat7

Session not maintained in tomcat7 on vps server



I am really stuck when it comes to running my jsp-servlet application on tomcat7 server installed on my VPS (having Ubuntu OS).
The problem is - Session is NOT maintained when application is run on VPS tomcat and so user is redirected to login page when he clicks any link.

The user should not be redirected to login page if he has already logged in and I stored his ID is session. This works properly when I try to run app on my localhost tomcat7 but doesn't work when deployed the application to tomcat7 on VPS.

Am I missing any configuration in VPS tomcat7 ? or Should I add/change anything in my application ?
I had installed tomcat7 using command > apt -get install tomcat7

Please help !!
Thanks


Solution

  • I got this figured out. The path where cookies are stored was incorrect and I had to include below lines in httpd.conf file in apache2 installed in VPS -

    <VirtualHost *:80>
      ServerName www.testdomain.com
      ServerAlias www.testdomain.com
      <Proxy *>
        Order deny,allow
        Allow from all
      </Proxy>
    
      ProxyPreserveHost Off
      ProxyPass               /       http://localhost:8080/testdomain/
      ProxyPassReverse        /       http://localhost:8080/testdomain/
      ProxyPassReverseCookiePath /testdomain/
    </VirtualHost>
    

    Thanks