You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Scott A. Roehrig" <sa...@hotmail.com> on 2001/12/02 04:59:07 UTC
ActionForward to anything other than a jsp
Hi:
I have read the archives and have seen some posts and responses to this question, but was hoping something more definitive might be posted.
Within an ActionA, I would like to forward to another ActionB to continue processing. Sounds reasonable. So, I look up the javadoc and see the section about ActionForward and think okay I would simply do the following in the first action
ActionForward forward = new ActionForward("/ActionServlet/ActionB");
return forward;
Well, so far no luck to say the least. I seem to always get 404 errors that the page can't be found. I have seen a post about bypassing the ActionForward and using the request.getRequestDispatcher and have not tried that yet since it seemed so logical that the ActionForward method should work.
No go, the only workaround I found was to have the forward to a .jsp page that did a <jsp:forward> to the actual action.
Can someone please let me know. Can an Action forward to another Action instead of a JSP page and if so why does the above method not work?
Thanks for any guidance.
Scott
Re: ActionForward to anything other than a jsp
Posted by Sean Owen <sr...@yahoo.com>.
You can definitely forward to other Actions directly. Typically you map your
Struts ActionServlet to "*.do" in web.xml. If you've done that, then the
forward below won't work unless it ends in ".do"; the URLs of Actions
typically end in this.
Just an aside... there is no problem with instantiating and returning a new
ActionForward object in your Action class, though usually you return an
ActionForward that is looked up from struts-config.xml, like "return
mapping.findForward("nextAction");".
Sean
----- Original Message -----
From: "Scott A. Roehrig" <sa...@hotmail.com>
To: <st...@jakarta.apache.org>
Sent: Sunday, December 02, 2001 3:59 AM
Subject: ActionForward to anything other than a jsp
Hi:
I have read the archives and have seen some posts and responses to this
question, but was hoping something more definitive might be posted.
Within an ActionA, I would like to forward to another ActionB to continue
processing. Sounds reasonable. So, I look up the javadoc and see the section
about ActionForward and think okay I would simply do the following in the
first action
ActionForward forward = new ActionForward("/ActionServlet/ActionB");
return forward;
Well, so far no luck to say the least. I seem to always get 404 errors that
the page can't be found. I have seen a post about bypassing the
ActionForward and using the request.getRequestDispatcher and have not tried
that yet since it seemed so logical that the ActionForward method should
work.
No go, the only workaround I found was to have the forward to a .jsp page
that did a <jsp:forward> to the actual action.
Can someone please let me know. Can an Action forward to another Action
instead of a JSP page and if so why does the above method not work?
Thanks for any guidance.
Scott
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: ActionForward to anything other than a jsp
Posted by Paul Devine <de...@hotmail.com>.
Hi Scott
I had this working. I do not have my code readily available so if you need
more specific information after reading this, please let me know and I will
send on a precise code snippet. I defined a local action forward within
the configuration of what you are calling ActionA, the local action forward
would forward to the name under which ActionB was itself defined in the
configuration file.
e.g. if the struts configuration file looks like:
<action name="/myactionA" ...etc.../>
<action name="myactionB" ...etc.../>
then I defined a <forward name="toActionB" path="/myActionB"/> within the
definition of ActionA and in the perform() method of ActionA i wrote code
that does a mapping.findForward("toActionB"). I recall it all worked this
way.
Please excuse any syntax errors above, as said I don't hvae my code to hand.
Just let me know if you want the precise code I can send it on tomorrow
- Paul
----- Original Message -----
From: "Scott A. Roehrig" <sa...@hotmail.com>
To: <st...@jakarta.apache.org>
Sent: Saturday, December 01, 2001 9:59 PM
Subject: ActionForward to anything other than a jsp
Hi:
I have read the archives and have seen some posts and responses to this
question, but was hoping something more definitive might be posted.
Within an ActionA, I would like to forward to another ActionB to continue
processing. Sounds reasonable. So, I look up the javadoc and see the section
about ActionForward and think okay I would simply do the following in the
first action
ActionForward forward = new ActionForward("/ActionServlet/ActionB");
return forward;
Well, so far no luck to say the least. I seem to always get 404 errors that
the page can't be found. I have seen a post about bypassing the
ActionForward and using the request.getRequestDispatcher and have not tried
that yet since it seemed so logical that the ActionForward method should
work.
No go, the only workaround I found was to have the forward to a .jsp page
that did a <jsp:forward> to the actual action.
Can someone please let me know. Can an Action forward to another Action
instead of a JSP page and if so why does the above method not work?
Thanks for any guidance.
Scott
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>