tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Funk <funk...@joedog.org>
Subject Re: how to customize HTTPSession
Date Sun, 23 Nov 2003 20:44:16 GMT
With the functionality you desire, stay away from the Session classes as 
defined in the servlet API. Any developer will be greatly confused if they 
try to read your code created by your description below since you are mixing 
well known terminology and assumptions.

Instead, look into Filters and HttpServletRequestWrapper and 
HttpServletResponse wrapper.

Ideally, you'd create some helper classes which do the gets and sets on the 
servletrequests and responses. How they get instantiated is up to you.


-Tim

ppalavilli@netscape.net wrote:
> Hi,
> 
> I am new to the java webapp development. I want to store some user data for my app in
a client side cookie rather than as a server side object and referencing it with a sessionId.
One of the main reasons for that is - we will be running multiple servers load balancing.
Since the HTTPSessions are java container instance specific - I don't want to use them. I
have read about distributed Session support - but it does involve complicated setup and seems
to be a overkill when compared to the data that I want to store.
> 
> Anyway - in that aspect - I have these 2 questions :
> 
> 1. Is there a way to override the HTTPSession and HTTPResponse provided by tomcat to
save the contents of the Session as a cookie instead of just storing the sessionId ? 
> 
> 2. If I implement my own Session class, and store it as a attribute in the HTTPRequest
object, how can I write the contents of the session as a cookie right before I return the
response ? The way I used to do it in other apps in C++ is to write a destructor for my session
object, which will get called when the request is being terminated and I could write the cookie
in the response. But the java equivalent to destructor "finalize()" is not gauranteed to be
called until the GC wakes up. So how can I make sure I set the cookie after the request is
completely processed?
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message