You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mark Takacs <mt...@yahoo.com> on 2002/02/06 19:27:54 UTC

ActionError in FormBeans -Redirect vs Forward

Hello,
   Im having what I hope is a misunderstand of the
useage of struts. 

summary: Error pages are shown with the underlying
servlet action URL instead of the JSP input URL

I've constructed a simple 2-page test app with one
servlet and one FormBeam.  

<action   path="/step1"
          name="stepForm"
          type="com.project68.Step1Action"
         input="/test/step1.jsp"
      validate="true"
         scope="session">
   <forward name="success" path="/test/step2.jsp"/>
   <forward name="goaway"  path="/test/blank.jsp"/>
 </action>

I've also defined the Structs application to use:

 <init-param>
   <param-name>forward</param-name>
   <param-value>
 org.apache.struts.action.RedirectingActionForward
   </param-value>
 </init-param>


This works wonderfully.   Step1.jsp enters some
values, and they show up on step2.jsp.  The step2.jsp
has the 'correct' url of 'step2.jsp'.  Keen. Go
Struts.

The problem comes in when there's a form validation
error.  (The type handled in the FormBean, not the
type you can intercept and handle inthe Action Class.)
  If I forget to fill in a form field, im redirected
to the input page and the error message shows up. 
wonderful..

My SOLE problem is that it's showing up via a FORWARD
instead of a redirect.

example:

url:  http://localhost/servlet/test1
  username: _________    (you must enter a value)
  first name: Mark


I'd much prefer to see

url:  http://localhost/test1.jsp
  username: _________    (you must enter a value)
  first name: Mark


I can get it to work if I was the <forward ...
redirect=true ..> method, but that means I have to
handle my FormErrors in the action myself, which
defeats the point of the nice auto-validation.  

Any help?  This happens in both struts 1.0.1 and in
struts1.1-dev (as of 2/5/2002).    Using tomcat4.0.1


-tak


__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>