troubleshooting Question

HttpSession, cookies & URL rewriting

Avatar of smiley_strat
smiley_strat asked on
JavaJava EE
2 Comments2 Solutions1004 ViewsLast Modified:
I have a web application running under Tomcat which uses the HttpSession object to track users' sessions.  The application is made up of some static HTML pages (for example, a frameset which contains a navigation menu) and servlets - not JSPs.

In my login servlet I use:

HttpSession s = request.getSession(true);

to establish the session and store some values such as UserID.

In other servlets, I use:

HttpSession s = request.getSession(false);

then I check if (s == null) which would mean there is no session, which means the user is not logged in.  If (s != null) I check some attributes of the session and proceed from there.

I have run into a problem where if the user does not have cookies enabled, the sessions are not being tracked, and therefore my "other" servlets think a user is not logged in, when in fact they have successfully logged in.  When cookies are enabled, everything is working properly.

My question is this:

If a user does not have cookies enabled, should the HttpSession object *automatically* use URL rewriting?  Is this something that I must set or configure in server.xml or web.xml?

If this functionality is not automatic (it doesn't seem to be, at least not the way Tomcat is configured now), how can I use the HttpSession object to track sessions without using cookies?

Thanks in advance for your assistance.





Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros