Please remember that you can only add cookies to the response BEFORE committing the response. That means, if you do write a (big) part of the result and Tomcat starts sending it to the browser, you will not be able to set any more cookies (or will not be sent to the browser anyway).

Yours,

Antonio Fiol

[EMAIL PROTECTED] 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?

Please pardon my ignorance if made any wrong assumptions. I would appreciate any help.
regards,
Praveen


__________________________________________________________________
McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!
http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397

Get AOL Instant Messenger 5.1 free of charge.  Download Now!
http://aim.aol.com/aimnew/Aim/register.adp?promo=380455

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to