JSP page to buffer in action
Is there a possibility to get my displayed page's contents in "as-is" format into my request in my struts (1.2) action?
ServletInputStream is = a_request.getInputStream();;
InputStreamReader isr = new InputStreamReader ( is );
BufferedReader bufRead = new BufferedReader ( isr );
while ((line = bufRead.readLine()) != null) {
result += line;
}
bufRead.close();
The value of result is "", I also tried to use
开发者_如何学PythonBufferedReader reader = a_request.getReader();
instead of the getInputStream, but didn't help, basically I want the JSP body into a buffer, so I can save it as HTML and convert it to PDF.
Has anyone an idea about this?
You'll have to use JavaScript to get the whole HTML source code of your page (see How to get the entire document HTML as a string? and How do I get the entire page's HTML with jQuery?), and submit it (using POST) to the server.
But if the PDF converter also needs the CSS, images etc. to convert the page to PDF, it might be much harder. In this case, one solution would be to send the current page URL to the server, so that the PDF converter loads this URL and gets everything it needs to do the conversion. This means however that the page shouldn't be protected, shouldn't be generated by JavaScript, etc.
精彩评论