You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jan Zimmek <ze...@piratez.net> on 2003/04/23 23:58:40 UTC

[OT] - fetching the response of a jsp as string

Hi,

i want to know if anyone knows a way to fetch the response of a jsp/servlet as string instead of sending the response to the client-browser ?

Most templateengines (Velocity, Webmacro, ...) support a method like:

public String fetch(NAME_OF_TEMPLATE);

which returns the evaluated template-response as string.

Due to the fact that a jsp is a servlet which directly sends the response to the client-browser, i am still not sure if a way exists to fetch the response instead of sending it to the client at all.

Any help would be appreciated.

Jan Zimmek

RE: [OT] - fetching the response of a jsp as string

Posted by Steve Armstrong <bi...@sympatico.ca>.
Hi,

Within a JSP page, if you want to capture the output of an action (i.e. the
result of an action forwarding to a JSP page or returning content itself),
or the contents of a JSP page directly (though Struts purists recommend that
you always go through an action to return content), I have used the
following in the past:

<bean:include id="tmp" forward="globalactionforwardreturningcontent"/>

Then, if you want to process these results in another action of your
choosing:

<bean:define id="content" name="tmp" scope="page" toScope="session"
type="java.lang.String"/>
<logic:forward name="globalactionforwardtoprocesscontent"/>

If "globalactionforwardreturningcontent" and
"globalactionforwardtoprocesscontent" are parameterized, rather than being
hard-coded as above, you can have a super simple Struts JSP page that
captures any type of content generation and subsequent processing.

Cheers,
-Steve

-----Original Message-----
From: Jan Zimmek [mailto:zet@piratez.net]
Sent: Wednesday, April 23, 2003 5:59 PM
To: struts-user@jakarta.apache.org
Subject: [OT] - fetching the response of a jsp as string


Hi,

i want to know if anyone knows a way to fetch the response of a jsp/servlet
as string instead of sending the response to the client-browser ?

Most templateengines (Velocity, Webmacro, ...) support a method like:

public String fetch(NAME_OF_TEMPLATE);

which returns the evaluated template-response as string.

Due to the fact that a jsp is a servlet which directly sends the response to
the client-browser, i am still not sure if a way exists to fetch the
response instead of sending it to the client at all.

Any help would be appreciated.

Jan Zimmek


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