Well, if all that Java code were in a servlet then it might have a chance of working. But as it is you're writing out HTML, not PDF. Look at the first two lines of what you're writing out:Even if you strip away everything except the scriptlets, I expect there will still be some whitespace that you let leak into the response. And that will mess up the PDF you send. Use a servlet instead.
You cannot do this in a JSP for exactly the reasons Paul mentioned. JSPs are solely inteneded to render character response data. Anything else, be it PDF, images or any other binary stream, must be emitted with a servlet.
Originally posted by mukul samak:
I can't use servlet since it is a Struts framework.
If you are doing it in struts, then do it from your Struts action. Its the equivalent of a servlet anyway. Just return null from your action to indicate to struts that you have already sent the response. And why are you writing it to a FileOutputStream? That would write the file out onto the server. Get the response output stream to send it back to the browser.
( a little bit of struts specific code, but not much)
I'm not sure if I approve of this interruption. But this tiny ad checks out: