Re: How to prevent FormBean validate() errors from showing up on logon page

2001-11-20 Thread Ted Husted

You may want to send them to a logon Action instead, which displayed the
logon page but had validate set to false. The page would then submit to
another Action  with validate set to true. You could also add a redirect
option to that mapping. (Which would also cure any problem with orphan
ActionErrors, since those are carried in the request.)

Generally, it is best to try and keep all JSP paths in the configuration
file, and refer to Actions everywhere else. This decouples the paths to
your JSPs from the rest of the application.

"T. Wheeler" wrote:
> 
> My application requires that users log on, so created a tag to check if the
> requester has already logged on.  If not, this tag redirects him to a logon
> page (/logon.jsp).
> 
> I have found that if the validate() method of the form bean returns errors
> and the user's session is lost (e.g. timed out), it takes the validation
> errors that it would normally display on the failure page and instead shows
> them on the /logon.jsp page (which also has an  tag).
> 
> Here are the steps I can take to demonstrate this effect:
> 
> 1.  Log on to the app with the browser.
> 
> 2.  Go to the /changePassword.jsp page.  Don't fill it out completely, so
> validate() will return errors.  Don't submit the page yet, either.
> 
> 3.  Restart the servlet engine (resin) which causes all sessions to be lost.
> 
> 4.  Submit the page that was loaded in step 2
> 
> 5.  The logon.jsp page is displayed, but so are the validation errors from
> the incomplete /changePassword.jsp form.
> 
> How can I prevent the validation errors from being displayed when
> redirecting to the logon page and still require users to log on?  I suspect
> that the form bean returns errors to the changePassword.jsp (and never calls
> the action class).  The changePassword.jsp has a  tag and
> this causes a forward to /logon.jsp
> 
> This is the relevant part of the code for the custom tag
> 
>   HttpSession session = pageContext.getSession();
>   if ((session != null) && (session.getAttribute(name) != null))
> valid = true;
> 
> if (valid)
>   return(EVAL_PAGE);
> else
> {
>   try
>   {
> // > how do I clear out all ActionErrors here? <
> pageContext.forward(page);
>   } catch (Exception e) {
> throw new JspException(e.toString());
>   }
>   return(SKIP_PAGE);
> }
>   }
> 
> Also, how could I redirect from within this custom tag instead of forward (I
> want the URL to change).
> 
> Any ideas?
> 
> Thanks in advance,
> 
> tw
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 

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




How to prevent FormBean validate() errors from showing up on logon page

2001-11-19 Thread T. Wheeler

My application requires that users log on, so created a tag to check if the
requester has already logged on.  If not, this tag redirects him to a logon
page (/logon.jsp).  

I have found that if the validate() method of the form bean returns errors
and the user's session is lost (e.g. timed out), it takes the validation
errors that it would normally display on the failure page and instead shows
them on the /logon.jsp page (which also has an  tag).

Here are the steps I can take to demonstrate this effect:

1.  Log on to the app with the browser.

2.  Go to the /changePassword.jsp page.  Don't fill it out completely, so
validate() will return errors.  Don't submit the page yet, either.

3.  Restart the servlet engine (resin) which causes all sessions to be lost.

4.  Submit the page that was loaded in step 2

5.  The logon.jsp page is displayed, but so are the validation errors from
the incomplete /changePassword.jsp form.

How can I prevent the validation errors from being displayed when
redirecting to the logon page and still require users to log on?  I suspect
that the form bean returns errors to the changePassword.jsp (and never calls
the action class).  The changePassword.jsp has a  tag and
this causes a forward to /logon.jsp

This is the relevant part of the code for the custom tag

  HttpSession session = pageContext.getSession();
  if ((session != null) && (session.getAttribute(name) != null))
valid = true;

if (valid)
  return(EVAL_PAGE);
else
{
  try
  {
// > how do I clear out all ActionErrors here? <
pageContext.forward(page);
  } catch (Exception e) {
throw new JspException(e.toString());
  }
  return(SKIP_PAGE);
}
  }

Also, how could I redirect from within this custom tag instead of forward (I
want the URL to change).

Any ideas?

Thanks in advance,

tw

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