You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chuck Cavaness <ch...@attbi.com> on 2002/04/23 05:36:36 UTC

Re: requestDispatcher.include rather than requestDispatcher.forward

Take a look at the org.apache.struts.actions.IncludeAction. It may be just 
what you need.

Chuck

At 12:42 PM 4/23/2002 +1000, you wrote:
>Team,
>
>I'm fairly new to Struts and would like to know if the following is possible.
>
>When returning an ActionForward object from the perfom method of a Action
>object, (usually acheived by mappings.findForward("name")) is it possible to
>have the Struts framework execute a requestDispatcher.include() rather than a
>requestDispatcher.forward()?
>
>ie:
>
>public class MyAction extends org.apache.struts.action.Action {
>   public org.apache.struts.action.ActionForward perform(
>       org.apache.struts.action.ActionMapping actionMapping,
>       org.apache.struts.action.ActionForm actionForm,
>       javax.servlet.http.HttpServletRequest request,
>       javax.servlet.http.HttpServletResponse response)
>         throws java.io.IOException, javax.servlet.ServletException {
>
>     // Is it possible that the Struts framework execute a
>     // requestDispatcher.include, rather than a forward on
>     // the resulting ActionForward?
>     return actionMapping.findForward("success");
>   }
>
>}
>
>--
>Regards,
>
>Brent Burgess
>JP
>#####################################################################################
>Attention:
>The information contained in this message and or attachments is intended
>only for the person or entity to which it is addressed and may contain
>confidential and/or privileged material. Any review, retransmission,
>dissemination or other use of, or taking of any action in reliance upon,
>this information by persons or entities other than the intended recipient
>is prohibited. If you received this in error, please contact the sender and
>delete the material from any system and destroy and copies.
>#####################################################################################
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>


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


Re: requestDispatcher.include rather than requestDispatcher.forward

Posted by Brent Burgess <br...@lumina.com.au>.
Thanks for the reply.

I've had to look at the source code for the 
org.apache.struts.actions.IncludeAction class before understanding the way to 
make it work.
I need to setup some page attributes before the requestDispatcher.include was 
called. Therefore I coded it as follows:

public class MyAction extends org.apache.struts.actions.IncludeAction {
  
  public org.apache.struts.action.ActionForward perform(
      org.apache.struts.action.ActionMapping actionMapping, 
      org.apache.struts.action.ActionForm actionForm, 
      javax.servlet.http.HttpServletRequest request, 
      javax.servlet.http.HttpServletResponse response) 
        throws java.io.IOException, javax.servlet.ServletException {

      // Setup the page attributes to be used by the included jsp     
      request.setAttribute("city", "Sydney");
      request.setAttribute("country", "Australia");
    
    return super.perform(actionMapping,actionForm,request,response);
  }
}

And it worked...
Thanks again.


On Tue, 23 Apr 2002 13:36, Chuck Cavaness wrote:
> Take a look at the org.apache.struts.actions.IncludeAction. It may be just
> what you need.
>
> Chuck
>
> At 12:42 PM 4/23/2002 +1000, you wrote:
> >Team,
> >
> >I'm fairly new to Struts and would like to know if the following is
> > possible.
> >
> >When returning an ActionForward object from the perfom method of a Action
> >object, (usually acheived by mappings.findForward("name")) is it possible
> > to have the Struts framework execute a requestDispatcher.include() rather
> > than a requestDispatcher.forward()?
> >
> >ie:
> >
> >public class MyAction extends org.apache.struts.action.Action {
> >   public org.apache.struts.action.ActionForward perform(
> >       org.apache.struts.action.ActionMapping actionMapping,
> >       org.apache.struts.action.ActionForm actionForm,
> >       javax.servlet.http.HttpServletRequest request,
> >       javax.servlet.http.HttpServletResponse response)
> >         throws java.io.IOException, javax.servlet.ServletException {
> >
> >     // Is it possible that the Struts framework execute a
> >     // requestDispatcher.include, rather than a forward on
> >     // the resulting ActionForward?
> >     return actionMapping.findForward("success");
> >   }
> >
> >}
> >
> >--
> >Regards,
> >
> >Brent Burgess
> >JP
> >##########################################################################
> >########### Attention:
> >The information contained in this message and or attachments is intended
> >only for the person or entity to which it is addressed and may contain
> >confidential and/or privileged material. Any review, retransmission,
> >dissemination or other use of, or taking of any action in reliance upon,
> >this information by persons or entities other than the intended recipient
> >is prohibited. If you received this in error, please contact the sender
> > and delete the material from any system and destroy and copies.
> >##########################################################################
> >###########
> >
> >--
> >To unsubscribe, e-mail:  
> > <ma...@jakarta.apache.org> For additional
> > commands, e-mail: <ma...@jakarta.apache.org>

-- 
Regards,

Brent Burgess
JP
#####################################################################################
Attention:
The information contained in this message and or attachments is intended
only for the person or entity to which it is addressed and may contain
confidential and/or privileged material. Any review, retransmission,
dissemination or other use of, or taking of any action in reliance upon,
this information by persons or entities other than the intended recipient
is prohibited. If you received this in error, please contact the sender and
delete the material from any system and destroy and copies.
#####################################################################################

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