On Fri, 30 Jul 2004 08:27:38 -0500, Mulligan, Scott H
<[EMAIL PROTECTED]> wrote:
> I have two distinct Struts applications running in Tomcat. I would like to
> forward a request from one application to the other and still be able to
> access the request attributes. Is this possible to do in the Struts
> framework without customizing the Controller? It seems that Struts can only
> forward to the same application. I don't want to use redirects. Has anyone
> done this before? Examples would be greatly appreciated.
> 

Forwarding like this would indeed require customization of the
controller, as well as customizing the ForwardConfig option that
defines where a forward goes.  Something along these lines might work:

* Create a subclass of ForwardConfig that takes an extra "context"
  property to pick up the context path of the other applicaton.

* In your struts-config.xml file, use the className element on your
  <forward> declarations to pick up this revised configuration class,
  and add the context attribute to declare the context path.

* Create a specialized subclass of RequestProcessor that overrides
   processForwardConfig() method:
  - If the passed ForwardConfig is not one of my special ones, just
    delegate to the superclass processForwardConfig() method.
  - Otherwise, call ServletContext.getContext() to get a reference
    to the other app's context, then call getRequestDispatcher()
    on that object to get the final RD.  (((Note - the current calling
    sequence doesn't make the ServletContext instance visible, so
    that will have to be faked somehow)))

Note that, by default, Tomcat installs do not allow cross context
calls like this, for security reasons.  There's a crossContext flag in
server.xml somewhere that enables it.

Craig


> Thanks!
> 
> Scott
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to