struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Barett McGavock <>
Subject RE: using redirecting forwards after failed validation
Date Wed, 17 Dec 2003 18:05:48 GMT
I did the following to get around the drawback with RequestProcessor that
you pointed out:
1) keep the ActionErrors as a request attribute
2) set the validate parameter to false for the ActionMapping
3) add code like the following to the search action itself:
errs = form.validate();
if (!errs.isEmpty()) {
  return mapping.getInput();

I've also seen a solution like this floating around the list in the last few

A note: this solution will forward to your input page, not redirect. I'm not
entirely sure from your message on why you'd like to redirect to the input.
It sounds like you're not set on it, so maybe a forward like the above will


-----Original Message-----
From: Par Winzell [] 
Sent: Wednesday, December 17, 2003 10:41 AM
Subject: using redirecting forwards after failed validation

Hello everyone -- this is my first post. I'm hoping you can help with a
problem. I've seen bits and pieces of this question asked, but not

Here's my problem:

When the user enters data into a 'enter search parameters' form and
validation fails, I don't want the URL to proceed to the 'perform the
search' action. This means I have to use redirecting forwards for the
'input' attribute.

However, with redirects... if I understand correctly... it's not good enough
to store validation errors in the request attributes. They need to go into
session scope. My problem is figuring out where this should happen.

Experimentally, I now mask validate(), which basically does

  errors = super.validate();
  request.getSession().setAttribute(ERROR_KEY, errors);
  return errors;

but this feels rather nasty to me; validate() is supposed to return values,
not cause side-effects... right?

The problem is that is entirely atomic all the way
from calling validate() to performing the redirect. Is there some other way
to do this that I'm missing? ... or should I not be doing what I'm doing? Is
there some other way to get redirection to work, with the validator

Appreciate any help --

Par Winzell
Madison, WI

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message