tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lightbulb432 <veerukrish...@hotmail.com>
Subject Race condition with values displayed across redirects
Date Thu, 04 Oct 2007 04:21:26 GMT

I have a question about whether there is a race condition with the following
technique for displaying messages across redirects.

If you submit a form with an invalid value on page P1 and the receiving
servlet S redirects to another page P2, you'd like page P2 to contain a
message saying "You entered an invalid value". You can only put the value in
the session (not the request, because it's a redirect, not a forward), with
session.setAttribute("message","You entered an invalid value").

In page P2, you'd display ${message}. But to ensure that the message doesn't
remain in the method upon every access to page P2, including when valid
information is submitted, you'd create a filter that applies to servlet S
with the following code:

chain.doFilter(request,response);
session.removeAttribute("message");

This method seems to work, but is there a race condition? My understanding
is that when a servlet does a redirect, the redirect occurs in a new thread
and the rest of the current servlet execution continues (including filters)
to completion in the current thread. Couldn't the filter on servlet S
complete execution (and remove the "message" attribute) before page P2
renders, thereby leaving ${message} empty?

Thanks.
-- 
View this message in context: http://www.nabble.com/Race-condition-with-values-displayed-across-redirects-tf4565759.html#a13032386
Sent from the Tomcat - User mailing list archive at Nabble.com.


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