tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lightbulb432 <>
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:


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?

View this message in context:
Sent from the Tomcat - User mailing list archive at

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message