On Thu, 21 Jun 2001, Bill Firestone wrote:

> >From an Action class, or perhaps from a subsequent jsp page, I want
> to include content from generated by another servlet -- a subservlet,
> if you will -- but the key is that the subservlet is a general
> resource in the server's servlet environment and should accessible
> either from within Struts or from outside of Struts.
> 
> The javadoc on http://jakarta.apache.org/struts/ has an
> ActionServlet.processInclude method.  But this javadoc looks like it's
> for Struts 1.1, not 1.0.
> 
> Is there a way in Struts 1.0 to invoke (include) another servlet and
> have it add content to the output?  If not, is it possible to
> "include" another servlet and have it return its content in an
> attribute so that the caller can include it in the output?

Support for forward/include is also available in Struts 1.0, as follows:

* You can use your subservlet as an Action itself, by
  forwarding to it:

    <action path="/mypath" forward="/mysubservlet" .../>

  NOTE:  No "type" attribute would be used here.

* You can use your subservlet as an Action itself, by
  including it (you would do this if the subservlet
  expects to be the target of a RequestDispatcher.include()):

    <action path="/mypath" include="/mysubservlet" .../>

  NOTE:  No "type" attribute would be used here.

* You can forward from your Action to a presentation JSP page
  in the usual way, and that JSP page can use <jsp:include>
  to merge in content from the subservlet.

* You can stitch together the output of multiple servlets by
  using RequestDispatcher.include() multiple times in your
  Action, although the previous method (using <jsp:include>)
  would generally be preferred.

See the documentation in struts-config_1_0.dtd for more info about the
first two options.

> 
> Thanks.
> 
> Bill
> 
> 

Craig


Reply via email to