This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes JSP and the fly likes Displaying a file on the browser without the download box. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Displaying a file on the browser without the download box." Watch "Displaying a file on the browser without the download box." New topic
Author

Displaying a file on the browser without the download box.

Kaustubh Patil
Ranch Hand

Joined: Aug 13, 2001
Posts: 164
The need in my application is that i have to display an attachment in the browser to the user. Now whenever i read the file (.txt,image,.doc,.pdf etc) in a byte array and write it to the out stream of the response.
Now whenever this happens the browser by default displays the "Download box". I want to skip this.
why does this download box appears.. and how can i avoid it ?
-thanks in advance for any help.
-Kaustubh.


Kaustubh. Mumbai, India.
Sreenivasa Majji
Ranch Hand

Joined: Jul 12, 2001
Posts: 224
Did you set the mime types properly? If the mime type didn't set or the client doesn't know how to handle the mime type coming from the server, it shows the dialog box.


Sreenivasa Majji
Kaustubh Patil
Ranch Hand

Joined: Aug 13, 2001
Posts: 164
Exactly..
the type of file is a pdf. so the browser cannot display it. so it probably invokes the plug-in for the pdf. this also happens in the case of excel files.
And i guess whenever it invokes the plug-in it displays the download box ,even if the content-type is set properly.
My question is can this be overridden ?
 
Consider Paul's rocket mass heater.
 
subject: Displaying a file on the browser without the download box.
 
It's not a secret anymore!