java - Get raw HTML in servlet to churn out a PDF file -


i have jsp rendered after forwarded servlet. have html jsp want post page in order generate pdf.

as per understanding submit button submits form. but, need submit raw html use flyingsaucer or similiar pdf creator library.

what way use html , save pdf file?

please chime in correct if wrong , think approach. advice appreciated.

edit: sorry have posted no code @ moment have hit wall in servlet in quest around this.

you've 2 options:

  1. let js set current html dom tree (hidden) request parameter on submit.

    <form method="post" action="pdfservlet">     <input type="hidden" name="source" />     <input type="submit" value="generate" onclick="this.form.source.value = document.documentelement.outerhtml;" /> </form> 

    it's in pdfservlet available request.getparameter("source").

  2. let pdfservlet request desired page programmatically using url/urlconnection.

    inputstream source = new url("http://localhost:8080/context/someservlet").openstream(); // ... 

    set if necessary jsessionid cookie current session id if need run in same session.

    urlconnection connection = new url("http://localhost:8080/context/someservlet").openconnection(); connection.setrequestproperty("cookie", "jsessionid=" + request.getsession().getid()); inputstream source = connection.getinputstream(); // ... 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -