File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Setting file extension Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Setting file extension" Watch "Setting file extension" New topic

Setting file extension

Aron Daburn
Ranch Hand

Joined: Mar 18, 2007
Posts: 36
I am needing to send a simple text file, but with a .license extension.

My code is as follows:

It is saving the file with .txt. I tried removing the response.setContentType and it saved it with .html. How do you set the extension on a file to .license?
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

MSIE is great at ignoring things like this.
Did you try setting the content type to 'text/license'?

If that doesn't work set the content type to something that the browser has never heard of like 'xxx/xxxx' and it will throw up a prompt saying that MSIE doesn't know what to do with this, Save or Open With?...

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Aron Daburn
Ranch Hand

Joined: Mar 18, 2007
Posts: 36
Yeah, I just tried setting its content type as the company name followed by '-license' and then that caused it to save it as a .license.

I agree. Here's the link:
subject: Setting file extension
It's not a secret anymore!