You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jason Novotny <ja...@gmail.com> on 2010/01/04 23:17:10 UTC

struts 1.3.8 trying to get the rendered output of a struts page from a plain servlet

Hi,

     I have a plain vanilla servlet and I want to "include" via the 
RequestDispatcher mechanism the rendered output of a struts page. Here's 
the code I have:

     ServletContext ctx = servletConfig.getServletContext();
       RequestDispatcher rd = 
ctx.getRequestDispatcher("/modules/foo/Home.do?myparam=value");
       if (rd != null) {

           StringWriter stringWriter = new StringWriter();
           MyResponse myresponse = new MyResponse(response, stringWriter);
           rd.include(request, myresponse);
           System.err.println(stringWriter.toString());

       }

I created MyResponse as a wrapper on ServletResponse that contains a 
buffer so I can pull out the contents. However, I'm not getting anything....

Has anyone done this before? Or is there some easy way to do this?

Thanks, Jason


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: struts 1.3.8 trying to get the rendered output of a struts page from a plain servlet

Posted by Paul Benedict <pb...@apache.org>.
Jason, I have only done this using JSTL tags. There is a <c:include>
(I believe) for this purpose.

On Mon, Jan 4, 2010 at 4:17 PM, Jason Novotny <ja...@gmail.com> wrote:
> Hi,
>
>    I have a plain vanilla servlet and I want to "include" via the
> RequestDispatcher mechanism the rendered output of a struts page. Here's the
> code I have:
>
>    ServletContext ctx = servletConfig.getServletContext();
>      RequestDispatcher rd =
> ctx.getRequestDispatcher("/modules/foo/Home.do?myparam=value");
>      if (rd != null) {
>
>          StringWriter stringWriter = new StringWriter();
>          MyResponse myresponse = new MyResponse(response, stringWriter);
>          rd.include(request, myresponse);
>          System.err.println(stringWriter.toString());
>
>      }
>
> I created MyResponse as a wrapper on ServletResponse that contains a buffer
> so I can pull out the contents. However, I'm not getting anything....
>
> Has anyone done this before? Or is there some easy way to do this?
>
> Thanks, Jason
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org