You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matthias Bauer <Ma...@livinglogic.de> on 2001/03/06 11:48:45 UTC

simple forward/redirect

Hi everybody!

There was a discussion about not calling jsp pages directly, but to always go
through an action instead. I agree that this makes a lot of sense it quite a few
cases.

Now my stupid question is: What do I have to enter in struts-config.xml in order
to do a simple forward or redirect e. g. from logon.do to logon.jsp?

Normally I would write something like this:

>     <!-- Process a user logon -->
>     <action    path="/logon"
>                type="login.LogonAction"
>         <forward name="success" path="/logon.jsp" />
>     </action>

But I don't need to do something special in the action LogonAction before
diplaying logon.jsp. So how do I come around this? Write a dummy action which
always returns success and use it in each of these cases?

Thanks a lot,

  --- Matthias

Re: simple forward/redirect

Posted by Thierry Cools <th...@s1.com>.
Yes that's what we did, using a simple
BasicAction class extending ActionBase that always return mapping.findForward("success") in the perform method.

Thierry

Thierry Cools
 
Senior Java Developer 
S1 Brussels 
Kleine Kloosterstraat, 23 
1932 st. Stevens-Woluwe 
Belgium 
Tel : +32 2 200 43 82 
Email : thierry.cools@s1.com 


  ----- Original Message ----- 
  From: Matthias Bauer 
  To: struts-user@jakarta.apache.org 
  Sent: Tuesday, March 06, 2001 11:48 AM
  Subject: simple forward/redirect


  Hi everybody!

  There was a discussion about not calling jsp pages directly, but to always go
  through an action instead. I agree that this makes a lot of sense it quite a few
  cases.

  Now my stupid question is: What do I have to enter in struts-config.xml in order
  to do a simple forward or redirect e. g. from logon.do to logon.jsp?

  Normally I would write something like this:

  >     <!-- Process a user logon -->
  >     <action    path="/logon"
  >                type="login.LogonAction"
  >         <forward name="success" path="/logon.jsp" />
  >     </action>

  But I don't need to do something special in the action LogonAction before
  diplaying logon.jsp. So how do I come around this? Write a dummy action which
  always returns success and use it in each of these cases?

  Thanks a lot,

    --- Matthias


Re: simple forward/redirect

Posted by Martin Quinn <ma...@irista.com>.
Please take me off this list.

Matthias Bauer wrote:

> Thanks for the quick response.
>
> Ana Narvaez Vila wrote:
> >
> > You could define a 'general' ForwardAction that simply makes the forward
> > in its perform.
> > Something like this.
> >
> > public ActionForward perform(ActionMapping mapping, ActionForm form,
> > HttpServletRequest request, HttpServletResponse response)
> > throws ServletMaravediNetException {
> >
> >         return (mapping.findForward("success"));
> >
> > }
> >
> > This class could be com.yourcompany.yourpackage.ForwardAction and you
> > could use it everytime that you want to do a simply forward or redirect.
> >
> >      <!-- Process a user logon -->
> >      <action    path="/logon"
> >                 type="com.yourcompany.yourpackage.ForwardAction"
> >          <forward name="success" path="/logon.jsp" />
> >      </action>
> >
> >      <action    path="/anotheraction"
> >                 type="com.yourcompany.yourpackage.ForwardAction"
> >          <forward name="success" path="/other.jsp" redirect="true"/>
> >      </action>
> >
> > Matthias Bauer wrote:
> > >
> > > Hi everybody!
> > >
> > > There was a discussion about not calling jsp pages directly, but to always go
> > > through an action instead. I agree that this makes a lot of sense it quite a few
> > > cases.
> > >
> > > Now my stupid question is: What do I have to enter in struts-config.xml in order
> > > to do a simple forward or redirect e. g. from logon.do to logon.jsp?
> > >
> > > Normally I would write something like this:
> > >
> > > >     <!-- Process a user logon -->
> > > >     <action    path="/logon"
> > > >                type="login.LogonAction"
> > > >         <forward name="success" path="/logon.jsp" />
> > > >     </action>
> > >
> > > But I don't need to do something special in the action LogonAction before
> > > diplaying logon.jsp. So how do I come around this? Write a dummy action which
> > > always returns success and use it in each of these cases?
> > >
> > > Thanks a lot,
> > >
> > >   --- Matthias
> > ------------------------------------------------------------------
> > This email is confidential and intended solely for the use of the individual to whom it is addressed. Any views or opinions presented are solely those of the author and do not necessarily represent those of Sema Group.
> > If you are not the intended recipient, be advised that you have received this email in error and that any use, dissemination, forwarding, printing, or copying of this email is strictly prohibited.
> > ------------------------------------------------------------------

Re: simple forward/redirect

Posted by Matthias Bauer <Ma...@livinglogic.de>.
Thanks for the quick response.

Ana Narvaez Vila wrote:
> 
> You could define a 'general' ForwardAction that simply makes the forward
> in its perform.
> Something like this.
> 
> public ActionForward perform(ActionMapping mapping, ActionForm form,
> HttpServletRequest request, HttpServletResponse response)
> throws ServletMaravediNetException {
> 
>         return (mapping.findForward("success"));
> 
> }
> 
> This class could be com.yourcompany.yourpackage.ForwardAction and you
> could use it everytime that you want to do a simply forward or redirect.
> 
>      <!-- Process a user logon -->
>      <action    path="/logon"
>                 type="com.yourcompany.yourpackage.ForwardAction"
>          <forward name="success" path="/logon.jsp" />
>      </action>
> 
>      <action    path="/anotheraction"
>                 type="com.yourcompany.yourpackage.ForwardAction"
>          <forward name="success" path="/other.jsp" redirect="true"/>
>      </action>
> 
> Matthias Bauer wrote:
> >
> > Hi everybody!
> >
> > There was a discussion about not calling jsp pages directly, but to always go
> > through an action instead. I agree that this makes a lot of sense it quite a few
> > cases.
> >
> > Now my stupid question is: What do I have to enter in struts-config.xml in order
> > to do a simple forward or redirect e. g. from logon.do to logon.jsp?
> >
> > Normally I would write something like this:
> >
> > >     <!-- Process a user logon -->
> > >     <action    path="/logon"
> > >                type="login.LogonAction"
> > >         <forward name="success" path="/logon.jsp" />
> > >     </action>
> >
> > But I don't need to do something special in the action LogonAction before
> > diplaying logon.jsp. So how do I come around this? Write a dummy action which
> > always returns success and use it in each of these cases?
> >
> > Thanks a lot,
> >
> >   --- Matthias
> ------------------------------------------------------------------
> This email is confidential and intended solely for the use of the individual to whom it is addressed. Any views or opinions presented are solely those of the author and do not necessarily represent those of Sema Group.
> If you are not the intended recipient, be advised that you have received this email in error and that any use, dissemination, forwarding, printing, or copying of this email is strictly prohibited.
> ------------------------------------------------------------------

Re: simple forward/redirect

Posted by Ana Narvaez Vila <an...@sema.es>.
You could define a 'general' ForwardAction that simply makes the forward
in its perform.
Something like this.

public ActionForward perform(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) 
throws ServletMaravediNetException {

	return (mapping.findForward("success"));

}

This class could be com.yourcompany.yourpackage.ForwardAction and you
could use it everytime that you want to do a simply forward or redirect.

     <!-- Process a user logon -->
     <action    path="/logon"
                type="com.yourcompany.yourpackage.ForwardAction"
         <forward name="success" path="/logon.jsp" />
     </action>

     <action    path="/anotheraction"
                type="com.yourcompany.yourpackage.ForwardAction"
         <forward name="success" path="/other.jsp" redirect="true"/>
     </action>

Matthias Bauer wrote:
> 
> Hi everybody!
> 
> There was a discussion about not calling jsp pages directly, but to always go
> through an action instead. I agree that this makes a lot of sense it quite a few
> cases.
> 
> Now my stupid question is: What do I have to enter in struts-config.xml in order
> to do a simple forward or redirect e. g. from logon.do to logon.jsp?
> 
> Normally I would write something like this:
> 
> >     <!-- Process a user logon -->
> >     <action    path="/logon"
> >                type="login.LogonAction"
> >         <forward name="success" path="/logon.jsp" />
> >     </action>
> 
> But I don't need to do something special in the action LogonAction before
> diplaying logon.jsp. So how do I come around this? Write a dummy action which
> always returns success and use it in each of these cases?
> 
> Thanks a lot,
> 
>   --- Matthias
------------------------------------------------------------------
This email is confidential and intended solely for the use of the individual to whom it is addressed. Any views or opinions presented are solely those of the author and do not necessarily represent those of Sema Group. 
If you are not the intended recipient, be advised that you have received this email in error and that any use, dissemination, forwarding, printing, or copying of this email is strictly prohibited.
------------------------------------------------------------------