Click to See Complete Forum and Search --> : JSP output saving
rbpierce
04-19-2005, 03:43 PM
Hi all, I hope this is the right forum. I wrote a report generator to provide custom reports to our clients in an html format. Naturally, I used jsp to do this to prevent a myriad of print statements. The problem comes in that I now need to be able to store the output as well as display it. I'd like to be able to either clone the output to both the default "out" stream and another print or filewriter, or perhaps pass the output through an intermediate printwriter before passing it to the default "out" stream. Does anyone have any notion as to where to start?
Khalid Ali
04-19-2005, 04:48 PM
are you storing only the out put that is generated by JSP or you want to store the whole html page?
rbpierce
04-19-2005, 04:59 PM
I need the entire html page, both the text displayed via jsp expressions as well as the encapsulating html displayed by placing it out of the <% and %> tags. Basically, I need everything going to the "out" JspWriter.
Khalid Ali
04-19-2005, 05:11 PM
one way of doing it will be to create a url connection to the page once it has been created and then read the contents out of the connection stream and print them to a file, shouldnt be more the 10 lines of code
rbpierce
04-20-2005, 08:22 AM
Thanks for the responses Khalid. If I am understanding you correctly, that is the one thing I don't want to do :) These reports take a long time to build, so it would behoove me to capture the output the first time through instead of having to make two requests, run two sets of data queries, etc. Do you have any other ideas? Quite frankly, I'm slamming into a brick wall here- I'm stumped.
Thanks again for the assistance- I do appreciate it.
Khalid Ali
04-20-2005, 01:04 PM
I guess one option could be that instead of using a jsp create the complete page's html using a servlet output stream and that way when you print it out to the page you can equally use the same stream to be written in the file.
using JSP causes a gap of focus. What happens that
1. page is not complete(partial HTML in jsp page)
2. jsp wills in the blanks
3. prints all dynamic data on jsp
4 completes html page and renders it in client browser.
after number 4 the page is out of scope for JSP to access unless it requsts hence your delima.
rbpierce
04-20-2005, 01:31 PM
Just an update. I finally hit upon wrapping the entire body in a custom tag- don't know why I didn't hit upon that before.
Khalid Ali
04-20-2005, 01:38 PM
good call, as I said it had to be on the serverside..:-)