Does anyone know how to save the output (html) of a jsp page to a file on the server? I want to save the html code that is sent to the browser as a file on the server.
buffer it and copy the buffer in a file (server side, for you), also copy the buffer in the PrintWriter (or anything you use to send back the answer to the user)
Do you have an example? I know how to use the printwriter to send content to a file but is there a way to send the buffer (or contents of) to the printwriter?
i don't have example right here ... but there are many at java.sun.com or at the java developper journal (sorry i lost the url)
it looks like this :
StringBuffer result = new StringBuffer("whatever"
result.append("whatever"
out.println(result);
The only problem is that the plain html content will not be output to file unless you write out everything using out.println(). blah
You may be able to extend your jsp from a custom base class that outputs to a file instead. I have never tried to change where the output stream writes. Good luck and let us know how it goes. I don't think it will be very hard. Wushutwist
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.