aspose file tools*
The moose likes Servlets and the fly likes How can I bypass the download dialogue box while downloading a file. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How can I bypass the download dialogue box while downloading a file." Watch "How can I bypass the download dialogue box while downloading a file." New topic
Author

How can I bypass the download dialogue box while downloading a file.

Fawad Ali
Ranch Hand

Joined: Dec 28, 2009
Posts: 112
Hi All,
I want to show an excel file in the browser. How can I bypass the download dialogue box and show it directly in the browser.


Regards, Fawad Ali.
Software Engineer, Stafona Inc. - My Blog
sudhir nim
Ranch Hand

Joined: Aug 29, 2007
Posts: 212

Set response content type to application/vnd.ms-excel , Don't add content-disposition header, and just write down the file to response steam. It will open up in browser instead of asking user to save.

[Servlet tutorial] [Servlet 3.0 Cook Book]
Pete Nelson
Ranch Hand

Joined: Aug 30, 2010
Posts: 147

Sudir Nim gives the best option, but keep in mind, the "save" dialog box is a function of the browser, and not the server. How the browser behaves when any file is accessed is based on the configuration of the browser.

With Sudir Nim's suggestion, the server gives a "hint" to the browser (it's not telling it to save via content-disposition), but it's still up to the browser to determine what to do.


OCPJP
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How can I bypass the download dialogue box while downloading a file.