This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Filetype in Firefox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Filetype in Firefox" Watch "Filetype in Firefox" New topic

Filetype in Firefox

Hakan Axheim

Joined: Nov 24, 2008
Posts: 9

I have a servlet that streams an ICalendar. As you can see I have used the setContentType and setHeader method in response objekt. When I use the IE 7.0 I receive an calender.ics file that should be downloaded to the filesystem but in Firefox the extension to the filename will be deleted. So the filename will be just calendar in Firefox but in IE it will be calendar.ics.

response.setContentType("text/calendar; charset=UTF-8");

OutputStream writer = response.getOutputStream();
ICALCalendar cal = (ICALCalendar) model.get("ical");
CalendarOutputter outputter = new CalendarOutputter();
outputter.output(cal.getCalendar(), writer);


Can anyone tell me whats wrong?

Leinad Jan

Joined: Feb 18, 2009
Posts: 28
I suggest you to use response.setHeader("ContentDisposition","attachment;filename=\"calendar.ics\"");

Like that, FireFox know that calendar.ics is a String.
It is sorta covered in the JavaRanch Style Guide.
subject: Filetype in Firefox
Similar Threads
Setting headers correctly in Javamail
Writing a FileOutputStream into a File
Trying to implement a mail queue in JavaMail using ExecutorService
Trying to create a threaded pool in JavaMail to deal with bulk mailing
Performing two actions in one event Liferay