sridevisd@gmail.com wrote on 27 Oct 2005 14:57:12 -0700 in
comp.lang.java.programmer:
>Hi,
>
[quoted text clipped - 29 lines]
>
>Where should I place the 'example.pdf' file so it can read it.
The way you're doing it above, you need to read the PDF file from the
disk and write it to the output stream yourself. You're only writing a
string of text and then closing the connection, which is what's
causing the "cannot be found" error.
>2. How can I open the Acrobat Reader inside the browser, instead of an
>attachment.
Use "inline; filename=example.pdf" as the Content-Disposition header.
If the example.pdf file exists somewhere where it can be served from a
simple URL, rather than being generated dynamically, then you can
redirect the browser to it with HttpServletResponse.sendRedirect().

Signature
Check out QueryForm, a free, open source, Java/Swing-based
front end for relational databases.
http://qform.sourceforge.net
If you're a musician, check out RPitch Relative Pitch
Ear Training Software.
http://rpitch.sourceforge.net
sridevisd@gmail.com - 28 Oct 2005 21:58 GMT
Thanks Dave. The 'inline'(inline; filename=\""+"example.pdf"+"\"")
worked when I read the pdf file and wrote to the output stream.
But the 'attachment' (attachment; filename=\"" +"example.pdf" +"\"")
is not working still.
Thanks
Sridevi
Dave Glasser - 28 Oct 2005 22:21 GMT
sridevisd@gmail.com wrote on 28 Oct 2005 13:58:01 -0700 in
comp.lang.java.programmer:
>Thanks Dave. The 'inline'(inline; filename=\""+"example.pdf"+"\"")
>worked when I read the pdf file and wrote to the output stream.
>
>But the 'attachment' (attachment; filename=\"" +"example.pdf" +"\"")
>is not working still.
Does the HTML link that invokes the URL have a target that opens
another browser window? For example, "<a target='_blank' href='...'"
or "<form target='_blank'? If so, I've encountered problems with IE
under WinXP SP2 when trying to download something as an attachment
that way. You have to make sure that whenever you're using
"attachment" that the target is the same browser window (the default).
It won't wipe out the contents, but rather should just bring up the
save dialog.

Signature
Check out QueryForm, a free, open source, Java/Swing-based
front end for relational databases.
http://qform.sourceforge.net
If you're a musician, check out RPitch Relative Pitch
Ear Training Software.
http://rpitch.sourceforge.net