Hello all,
So,I am using
JSF for the first time.I am able to produce the pdf using HTML & FOP but for my project I want it using JSF.
Basically I have done till I am able to call the backing bean function which is nothing but FOP class which responses back the PDF....
But the problem I am facing with JSF is that I can see the PDF generating on the server console but I can't get it streamed to the browser JSF page where I want to see the PDF ..(Basically PDF is generated using some other XML and XSL file using FOP program and then streamed to browser...and am doing this all on localhost) ....
But instead of loading the pdf am loading the same page where I clicked the getPDF....
I am using following bean function for the response...
public void renderXML(XSLTInputHandler input,
HttpServletResponse response) throws ServletException {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
response.setContentType("application/pdf");
Driver driver = new Driver();
driver.setLogger(log);
driver.setRenderer(Driver.RENDER_PDF);
driver.setOutputStream(out);
driver.render(input.getParser(), input.getInputSource());
byte[] content = out.toByteArray();
response.setContentLength(content.length);
response.getOutputStream().write(content);
response.getOutputStream().flush();
} catch (Exception ex) {
throw new ServletException(ex);
}
Please anybody help me out....
This is DO OR DIE FOR ME TILL MONDAY....