I want to convert a JSP page to a PDF. For this I am using a third party library which accepts HTML as input.
So, on the server side, I have to get the complete HTML which is the result after the JSP is rendered and then pass the same HTML to my third party library.
I am able to accomplish this by writing a filter, which wraps the response in to byte array output stream. I am able to get the complete HTML of the rendered JSP including the rendering of Tiles. This thing cannot be achieved in a controller or servlet as I need to final HTML output(including tiles, any JSP tags present in the JSP and others)
But, as per the requirement, I need to get some information from the DB and so I thought interacting with DB from a filter is not a good idea. Can anyone suggest a good place where I can do this instead of a filter?
I tried accessing the BO or DAO object from the Filter, but as my application using spring dependency injection, I have to invoke the filter also using spring which is not possible and so the BO and DAO and jpaDataAccess object in the DAO can’t be auto wired.
So, instead of getting the complete HTML in filter, Please suggest a good place where and how I can accomplish the same.
Joined: May 09, 2012
Figured it out!!
We can do a request dispatcher in the normal Spring controller passing a wrapped response.
We can get the complete HTML from that response object.