servlet, mime-type, edi, xml ...

Y

Yann.PETIT

Hello everybody,


I'm currently serving XML or EDI files through a servlet.
I'd like to have a download function, I mean whan the user clicks on a
button it opens the "save as" window.

Unfortunately, XML is automatically recognized by IE and it displays it
without prompting whether I'd like to view it or saveit.

And I have the same king of problem with EDI files, they are in plain
text format so they are just displayed and not downloaded through the
"save as" window.

I've tried to play with mime types, and I found that if the mime type
isn't recognized by my browser it allows to save the file. But the
default file name is set to "myservlet.do" .

QUESTION: Is there a specific mime type for EDI ?

QUESTION: Is there another mime type than text/xml which would allow me
to let my xml flow be downloadable instead readable.

QUESTION: Is there a way to change the default name when downloading a
file (changing http headers may be but which one and how ?)


Many thanks by advance.


Yann
 
S

shakah

Hello everybody,


I'm currently serving XML or EDI files through a servlet.
I'd like to have a download function, I mean whan the user clicks on a
button it opens the "save as" window.

Unfortunately, XML is automatically recognized by IE and it displays it
without prompting whether I'd like to view it or saveit.

And I have the same king of problem with EDI files, they are in plain
text format so they are just displayed and not downloaded through the
"save as" window.

I've tried to play with mime types, and I found that if the mime type
isn't recognized by my browser it allows to save the file. But the
default file name is set to "myservlet.do" .

QUESTION: Is there a specific mime type for EDI ?

QUESTION: Is there another mime type than text/xml which would allow me
to let my xml flow be downloadable instead readable.

QUESTION: Is there a way to change the default name when downloading a
file (changing http headers may be but which one and how ?)


Many thanks by advance.


Yann

For the last two questions, check out the "Content-Disposition"
response header (http://www.faqs.org/rfcs/rfc1806.html). You might end
up with something like:
response.setHeader("Content-Disposition", "attachment;
filename=file.edi") ;

In addition, a way to work around IE (sometimes?) disregarding the
Content-Type header is to append a useless parameter on the end of the
URL, e.g.:


http://yourhost/servlet/YourServlet?paramA=12&paramB=7&ieparam=file.edi
 
Y

Yann.PETIT

Thank you very much !

Your first solution using the content-dsiposition header seems to work
perfectly !

Yann
 
Y

Yann.PETIT

Hi again,

The only problem with IE , is that it by default consider the document
as an HTML document in the "save as" popup. So if you don't take care
of that your file will saved as : filename.EDI.html :eek:(

But if you change to "all files" in the document ype selector, it's
saved as filename.EDI

Yann
 
S

shakah

Hi again,

The only problem with IE , is that it by default consider the document
as an HTML document in the "save as" popup. So if you don't take care
of that your file will saved as : filename.EDI.html :eek:(

But if you change to "all files" in the document ype selector, it's
saved as filename.EDI

Yann

I'd think a combination of a Content-Type header and adding a useless
parameter to the URL to make it end with ".edi" would take care of that.
 
Y

Yann.PETIT

Yes using content-type : text/edi IE by default save the file as
filename.EDI .

==> all problems solved .

Thank you very much !

Yann
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top