Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Setting File Name in response

843841Jan 30 2004 — edited Oct 30 2008
Hi,

On server side I read the (Pdf) file and then stream the file content thru response object so that this pdf file opens in browser using Adobe reader. This works just fine.

And right now, if user wants to save this file in browser, complete jsp url appears as file name in save as dialog box.
For eg.:
If my jsp has stream the pdf file from this url
http://www.xy.com/jsp/displayFileJsp?f=xyz.pdf

then
when user tries to save this file, browser save as dialog displays file name as "http://www.xy.com/jsp/displayFileJsp?f=xyz.pdf"

But I want user should download that file name with specific file name like xyz.pdf.

I tried to set the content type
response.setHeader("Content-Disposition", " filename=xyz.pdf" );

But it didn't work.

any suggestions ?
rk
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 27 2008
Added on Jan 30 2004
17 comments
5,152 views