Question

I have a problem that I have been scouring the internet for the past few days. I have found people with similar problems but whos solutions didn't advance my state.

What is most irritating is that I have been working with this before, without problems or any blocks.

The thing is that my sessions on my java web application, is either getting deleted inbetween requests or not create correctly to begin with.

Some simple trouble shooting:

  • I can create and use cookies just fine.
  • Every time I refresh or follow a link to a servlet or jsp, the jsessionid is getting a new id.
  • On chrome, I can not see the session cookie (but other cookies I can).
  • On firefox, I can see the session cookie (and also that its id is changing at every request).

I have had this to work before without even giving it as much as a single thought.

I just use the: In jsp I just session.get/setAttribute() In servlet I just request.getSession()

I have also looked into the getSession(boolean created), but as far as Im concerned getSession() should do it for me?

My server is running Tomcat 7 and have Servlet 3. I can see the with servlet 3, that I have to declare some things in the web.xml file, my session config is as follows: <session-config> <session-timeout>30</session-timeout> <tracking-mode>COOKIE</tracking-mode> </session-config>

You think im doing something wrong in my code? it seems far to simple, and have used it times before. But this is the first time I have had the task to also setup the servers configuration.

This is my first post on stackoverflow, have found many answers before here, and hope someone can tell me where I am being an idiot. Hope I have given comprehensive details. Thanks in advance.

Was it helpful?

Solution

Sometimes its hard to search for a solution, when you don't exactly know what the problem is.

The problem was with the apache proxy setup for tomcat.

Here is the link for anyone else that might stumble upon my way of formulating the problem.

Apache 2.2 Virtual hosts + Tomcat 7 applications

adding ProxyPassReverseCookiePath /testapp / to the httpd config.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top