The moose likes JSP and the fly likes how to set the download mode Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "how to set the download mode" Watch "how to set the download mode" New topic

how to set the download mode

Ritu Pande

Joined: Jun 05, 2005
Posts: 17

i m creating an application which queries the database and store the result in excel sheet on application server which runs under unix
operating system. i m providing link to download the excel sheet in jsp page. it is working, but the problem is that whenever it is
downloading the excel sheet it is in ascii mode because of which i m not getting file in excel sheet. is there any other way where i
can set download mode.

thnx in advance

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

If your just providing a link to a file, the server should take care of this for you. You may need to add a mime type entry for a particular file. In Tomcat, the mime types are in the global web.xml (the one in the conf directory).

If you're streaming the file to them from a database or location outside of the sections of your app that are accessible to browsers, you'll need to set the content type and the content disposition headers.

I have an example application that streams images from a directory under WEB-INF. It should have enough code to get you going. Look for SimpleStream.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
kirtikumar patel

Joined: Jun 29, 2005
Posts: 14
whatever reply has been given by

Ben Souther
ranch hand
Member # 88262
is correct one .and you also send all detail relative to file in header.

kirti patel<br />software engiener<br />pune
I agree. Here's the link:
subject: how to set the download mode
It's not a secret anymore!