File Download Dialog

Discussion in 'Java' started by pharaohseti, Jul 6, 2007.

  1. pharaohseti

    pharaohseti Guest

    Hi to the group...

    I have an Excel (XLS) file in my server. I want my ERP users to click
    a button and download that file. But i couldn't change web.xml because
    of project settings. Because of that i can't use MIME types....

    I used this code in my java file:

    public void download() {
    String filename = "/ornek.xls";
    java.io.File file = new java.io.File(filename);
    java.io.FileInputStream fis = new java.io.FileInputStream(file);

    javax.activation.FileTypeMap ftm = new
    javax.activation.MimetypesFileTypeMap();
    response.setContentType(ftm.getContentType(filename));

    response.setHeader("Content-Disposition","attachment; filename="
    + file.getName() + ";");
    int iRead;
    while ((iRead = fis.read()) != -1) {
    response.getOutputStream().write(iRead);
    }
    response.getOutputStream().flush();
    }

    and then i put these lines to my jsp page:

    <dos:submit value="Download" width="120" islem="download"
    id="btnIndirExcel" validation="false" />

    dos is our frameworks name. Don't mess with it up.

    But when i use this approach and compile, while testing i click and
    the dialog opens up i save the file but the Download button becomes
    gray until i press F5. How can i find a solution. Thanks a lot...
     
    pharaohseti, Jul 6, 2007
    #1
    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. Daniel Cardoso
    Replies:
    1
    Views:
    792
    Daniel Cardoso
    Sep 24, 2004
  2. Ryan Taylor
    Replies:
    2
    Views:
    1,007
    Ryan Taylor
    Nov 10, 2004
  3. Sam --
    Replies:
    2
    Views:
    656
    Sam --
    Mar 17, 2005
  4. Kele
    Replies:
    0
    Views:
    2,815
  5. =?Utf-8?B?SWJyYWhpbS4=?=

    File name is displayed Garbled in "File download dialog box"

    =?Utf-8?B?SWJyYWhpbS4=?=, Aug 12, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    492
    =?Utf-8?B?SWJyYWhpbS4=?=
    Aug 12, 2006
Loading...

Share This Page