This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes Force client application to open download Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Force client application to open download" Watch "Force client application to open download" New topic
Author

Force client application to open download

jaron schut
Greenhorn

Joined: Sep 19, 2007
Posts: 5
Hello,

I have a downloadservlet that exports a comma-separated-value file to the client. The file contains name / email / etc of people. These should be imported into MS outlook or other applications.

How do I manipulate that MS-outlook or outlook express opens the download. Currently it appears that excel is allways the default program that opens the file.

I tried various contentTypes:

response.setContentType("text/csv");
response.setContentType("application/outlook");
response.setContentType("application/msoutlook");
response.setContentType("application/x-outlook");
response.setContentType("application/x-msoutlook");

It doesn't seem to help. They all have the same effect.

Googling doesn't help either since the search results just get spammed with outlook download attachment tutorials.

Is it possible at all? If possible how do I accomplish it?


Kind regards


SCJP 1.4<br />SCWCD 1.4<br />SCBCD 5<br />ICSD
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I assume you're using IE?

The behaviour is different between browsers, but IE also looks at the file extension, you can provide a filename, I just remember how... I'll go look.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Sorry, I just read that you want to encourage the client to open a CSV in outlook and not Excel. Unfortunately the browser will do whatever the default is, which will usually be Excel.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Force client application to open download