Thanks Mark - the problem with using HTTPSessionBindingListener is that the unbound 
event is not triggered unless someone calls the session.removeAttribute() or 
session.setAttribute(name, null). So there is no way for me to set the cookie from the 
unbound() event without explicitly calling one of the above 2 methods, which ofcourse 
is not possible in real world. Please correct me if I am wrong.

I think what I should be looking for is a way to attach a listener to the HTTPRequest 
itself, which the HTTPRequest can notify corresponding to an attribute when it is set 
in the request using the request.setAttribute() method and when it is removed either 
using the request.removeAttribute() method or when the HTTPRequest itself unbinds the 
attribute when it is done processing a request.

thanks
Praveen


"Mark R. Diggory" <[EMAIL PROTECTED]> wrote:

>You might look into implementing the
>javax.servlet.hhtp.HttpSessionBindingListener interface, this will allow
>you to act when an object is added/removed from the session. Simply put, 
>you could write valueBound/UnBound methods that set Cookies into the 
>HttpResponse.
>
>-Mark
>
>[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
>> 
>-- 
>Mark Diggory
>Software Developer
>Harvard MIT Data Center
>http://www.hmdc.harvard.edu
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>

__________________________________________________________________
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]

Reply via email to