tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Caldarale, Charles R" <Chuck.Caldar...@unisys.com>
Subject RE: URL rewriting For Session Tracking
Date Thu, 04 Jan 2007 05:56:03 GMT
> From: jobs@ultratechpartners.com [mailto:jobs@ultratechpartners.com] 
> Subject: Re: URL rewriting For Session Tracking
> 
> Basically I have a webapp and I want to have a session
> for each user that connects to my server (just the usual
> servlet session that is created with jsessionid).  Do I
> have to wrap every link that I have in my webapp with an 
> Httpservletresponse.encodeURL()?

No.  As I recall, Tomcat will not create a session automatically unless
it's absolutely necessary (e.g., tracking authenticated users) or the
application requests it.  I'm not aware of any config parameter that
will force creation of sessions for all clients, but all you should have
to do is put the following somewhere in the request processing path of
each servlet:
        request.getSession(true);

This doesn't need to go into your servlet or JSP code - you can write a
simple filter class that does nothing but run the above code to force
the creation of a session if one doesn't already exist.  The filter
mapping can go into conf/web.xml so it will apply to all apps deployed
within your Tomcat instance, or in each appropriate webapp's web.xml
file.

Note that per the servlet spec, Tomcat will use cookies not URL
rewriting for session tracking; it will fall back to URL rewriting if
the client refuses cookies.  You can also disable use of cookies by
setting cookies="false" in your <Context> elements (or the global
conf/context.xml file).

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message