Ask the Expert

How can we display an Open/Save As dialog box for multiple files?

We want to develop a JSP/Servlet page where user can select and download multiple files. The requirement is to download all the requested files in a single request/response cycle. We need to show an Open/Save As dialog box to the user on a JSP page separately for each downloaded file. How can we achieve this? Is it possible to display the Open/Save As dialog box separately for each file? Can we use Javascript to do this? If yes, how?

    Requires Free Membership to View

Multiple files are quite simple to specify. The following JSP demonstrates this:
<html>
<head>
<title>Download File</title>
</head>
<body>
    <form name="DownloadFileForm"
          action="/mywebapp/servlet/MyServlet"
          method="post"
          enctype="multipart/form-data">
      <table width="100%" border="0" cellpadding="1"
cellspacing="0">
        <tr><td nowrap>File 1: <input name="file1"
                                      type="file"
                                      size="80"></td></tr>
        <tr><td nowrap>File 2: <input name="file2"
                                      type="file"
                                      size="80"></td></tr>
        <tr><td nowrap>File 3: <input name="file3"
                                      type="file"
                                      size="80"></td></tr>
        <tr><td nowrap>File 4: <input name="file4"
                                      type="file"
                                      size="80"></td></tr>
        <tr align="center" valign="top">
          <td width="100%">
            <input type="submit"
                   name="submit"
                   value="Submit"
                   alt="Submit"
          </td>
        </tr>
      </table>
   </form>
</head>
You can use Javascript to validate the input fields, if you want to, but gathering the file names is simple HTML.

This was first published in January 2004

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: