java servlet :: how to download multiple files

Discussion in 'Java' started by anil001, Aug 19, 2003.

  1. anil001

    anil001 Guest

    my requirement is to download multiple files on click of submit button.
    At present the following code sniplet downloads single files
    ----------------------------------------------------------------
    response.setContentType("application/download");
    response.setHeader("Content-disposition","attachment; filename=" + strAttachName);
    response.getOutputStream().write(ByteArray());
    ----------------------------------------------------------------
    does anybody know it?

    thx
    anil001, Aug 19, 2003
    #1
    1. Advertising

  2. anil001

    biro Guest


    > my requirement is to download multiple files on click of submit
    > button.
    > At present the following code sniplet downloads single files
    > ----------------------------------------------------------------
    > response.setContentType("application/download");
    > response.setHeader("Content-disposition","attachment; filename=" +
    > strAttachName);
    > response.getOutputStream().write(ByteArray());
    > ----------------------------------------------------------------
    > does anybody know it?



    If you mean you want the server to send the user several files after they
    click submit once, then I don't think its possible.
    biro, Aug 19, 2003
    #2
    1. Advertising

  3. biro wrote:
    >
    > > my requirement is to download multiple files on click of submit
    > > button.
    > > At present the following code sniplet downloads single files
    > > ----------------------------------------------------------------
    > > response.setContentType("application/download");
    > > response.setHeader("Content-disposition","attachment; filename=" +
    > > strAttachName);
    > > response.getOutputStream().write(ByteArray());
    > > ----------------------------------------------------------------
    > > does anybody know it?

    >
    > If you mean you want the server to send the user several files after they
    > click submit once, then I don't think its possible.


    I'm also pretty sure that the way http works you can send only one
    response; since a response corresponds to a file for a download, that
    would mean you could send only one file.

    For the content type you have listed, it seems that you would want to
    put them all into a zip file and just send that. But, if it's supposed
    to be dynamic content, you probably wouldn't want to have all possible
    combinations of files stored in advance. If you want to build the zip
    on the fly, see: http://www.mike-levin.com/java/zipoutputstream.html .

    Otherwise, you could return an html page that lists all the individual
    files as links, and let the user manually download each one (or come up
    with a scheme that automates that process).


    --
    Steve
    --
    http://www.steveclaflin.com
    Steve Claflin, Aug 19, 2003
    #3
    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.

Share This Page