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

Discussion in 'Java' started by Yann.PETIT@gmail.com, May 17, 2005.

  1. Guest

    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
     
    , May 17, 2005
    #1
    1. Advertising

  2. shakah Guest

    wrote:
    > 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
     
    shakah, May 17, 2005
    #2
    1. Advertising

  3. Guest

    Thank you very much !

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

    Yann
     
    , May 18, 2005
    #3
  4. Guest

    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
     
    , May 18, 2005
    #4
  5. shakah Guest

    wrote:
    > 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.
     
    shakah, May 18, 2005
    #5
  6. Guest

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

    ==> all problems solved .

    Thank you very much !

    Yann
     
    , May 19, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. circuit_breaker
    Replies:
    2
    Views:
    2,061
    Jack Jia
    Apr 4, 2004
  2. CJ
    Replies:
    1
    Views:
    1,603
    Andrew Thompson
    Oct 29, 2004
  3. Replies:
    0
    Views:
    837
  4. Jan Arickx
    Replies:
    0
    Views:
    216
    Jan Arickx
    Aug 25, 2003
  5. joe
    Replies:
    0
    Views:
    213
Loading...

Share This Page