Getting result of JSP before sending to client

View: New views
4 Messages — Rating Filter:   Alert me  

Getting result of JSP before sending to client

by Steven Yang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

I am wondering is there a way in Struts2 to get the result of JSP before
returning the composed HTML back to client?

for example

public String execute() {
   ...do my logic and prepare my data

  ...then using the data, compose a HTML file from existing jsp

... then i need to save the HTML file somewhere

...then
return SUCCESS; --> maybe to same HTML or other JSP
}

Thanks

Re: Getting result of JSP before sending to client

by Musachy Barroso :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

you can use the embeddedjsp plugin to process a jsp as a template
library without using the container. another alternative is to create
your own filter and create a response object which will have a writer
to capture what is written to it, so you can modify it and then write
it to the real output stream.  Can you tell us what you are trying to
do? maybe you don't need a jsp and could use freemarker or velocity.

musachy

On Wed, Oct 28, 2009 at 6:28 PM, Steven Yang <kenshin520@...> wrote:

> Hi
>
> I am wondering is there a way in Struts2 to get the result of JSP before
> returning the composed HTML back to client?
>
> for example
>
> public String execute() {
>   ...do my logic and prepare my data
>
>  ...then using the data, compose a HTML file from existing jsp
>
> ... then i need to save the HTML file somewhere
>
> ...then
> return SUCCESS; --> maybe to same HTML or other JSP
> }
>
> Thanks
>

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


Re: Getting result of JSP before sending to client

by Steven Yang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i will take a look at embeddedjsp plugin

actually what we are doing is
we have a form/survey and after user completes it, we, originally, want to
save it as PDF which would have no problem for me, but due the time
constraint we decided to simply save the file/report as HTML, thats why i
want to know whats the simplest way to do it.
The saved HTML may or may not look exactly the same as the page we return to
the user, i am not sure yet.

thanks

On Thu, Oct 29, 2009 at 2:28 PM, Musachy Barroso <musachy@...> wrote:

> you can use the embeddedjsp plugin to process a jsp as a template
> library without using the container. another alternative is to create
> your own filter and create a response object which will have a writer
> to capture what is written to it, so you can modify it and then write
> it to the real output stream.  Can you tell us what you are trying to
> do? maybe you don't need a jsp and could use freemarker or velocity.
>
> musachy
>
> On Wed, Oct 28, 2009 at 6:28 PM, Steven Yang <kenshin520@...> wrote:
> > Hi
> >
> > I am wondering is there a way in Struts2 to get the result of JSP before
> > returning the composed HTML back to client?
> >
> > for example
> >
> > public String execute() {
> >   ...do my logic and prepare my data
> >
> >  ...then using the data, compose a HTML file from existing jsp
> >
> > ... then i need to save the HTML file somewhere
> >
> > ...then
> > return SUCCESS; --> maybe to same HTML or other JSP
> > }
> >
> > Thanks
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>

Re: Getting result of JSP before sending to client

by Steven Yang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi i just looked at embeddedjsp plugin
it requires JAVA 1.6 which i am not using, only using 1.5.

i also need to make sure saving the HTML is in the same Transaction(database
transaction) as saving the record. Therefore, intercepting the result in
filter may not be a solution for me.

is there other way?

Thanks

On Thu, Oct 29, 2009 at 3:24 PM, Steven Yang <kenshin520@...> wrote:

> i will take a look at embeddedjsp plugin
>
> actually what we are doing is
> we have a form/survey and after user completes it, we, originally, want to
> save it as PDF which would have no problem for me, but due the time
> constraint we decided to simply save the file/report as HTML, thats why i
> want to know whats the simplest way to do it.
> The saved HTML may or may not look exactly the same as the page we return
> to the user, i am not sure yet.
>
> thanks
>
>
> On Thu, Oct 29, 2009 at 2:28 PM, Musachy Barroso <musachy@...>wrote:
>
>> you can use the embeddedjsp plugin to process a jsp as a template
>> library without using the container. another alternative is to create
>> your own filter and create a response object which will have a writer
>> to capture what is written to it, so you can modify it and then write
>> it to the real output stream.  Can you tell us what you are trying to
>> do? maybe you don't need a jsp and could use freemarker or velocity.
>>
>> musachy
>>
>> On Wed, Oct 28, 2009 at 6:28 PM, Steven Yang <kenshin520@...>
>> wrote:
>> > Hi
>> >
>> > I am wondering is there a way in Struts2 to get the result of JSP before
>> > returning the composed HTML back to client?
>> >
>> > for example
>> >
>> > public String execute() {
>> >   ...do my logic and prepare my data
>> >
>> >  ...then using the data, compose a HTML file from existing jsp
>> >
>> > ... then i need to save the HTML file somewhere
>> >
>> > ...then
>> > return SUCCESS; --> maybe to same HTML or other JSP
>> > }
>> >
>> > Thanks
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@...
>> For additional commands, e-mail: user-help@...
>>
>>
>