Hi

Change to

response.setHeader("Content-Disposition","download;
filename=output.pdf;");

Let me know if it works.

Thanks & Regards
Gurvinder

-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED] On Behalf Of Jasthi Bhanu Prasad
(CTC)
Sent: Wednesday, February 11, 2004 3:38 PM
To: [EMAIL PROTECTED]
Subject: Problem with Uploading file from JSP/Servlet to Client machine.

Hi all,
        I'm using following code to upload file from servlet to client
machine for saving that in the client machine.
        But, I could only see the dialogue box with "save" "Open"
"cancel".
If I click 'Open" it is reporting file corruption. If I save, I can see
the
size of file as 1 byte.
        Can any one help me by pointing the mistake in the code? or
correct
approach....

                        FileInputStream fo = new
FileInputStream("c:\\tech.pdf");
                        response.setContentType("application/pdf");

response.setHeader("Content-Disposition","attachment;
filename=output.pdf;");
                        javax.servlet.ServletOutputStream out =
response.getOutputStream();
                        long avl = 0;
                        while( (avl = fo.available()) != 0)
                        {
                                byte[] bytes = new byte[(int)avl];
                                out.write(fo.read(bytes));
                        }
                        out.flush();
                        out.close();
                        fo.close();

        Thanks and Regards,
          Bhanu

========================================================================
===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com
-------------------------------------------------------------------------------------

The information contained in this message is proprietary of Amdocs,

protected from disclosure, and may be privileged.

The information is intended to be conveyed only to the designated recipient(s)

of the message. If the reader of this message is not the intended recipient,

you are hereby notified that any dissemination, use, distribution or copying of

this communication is strictly prohibited and may be unlawful.

If you have received this communication in error, please notify us immediately

by replying to the message and deleting it from your computer.

Thank you.

---------------------------------------------------------

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com

Reply via email to