Q

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?
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

Dig deeper on Java Web Services

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

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:

SearchSoftwareQuality

SearchCloudApplications

SearchAWS

TheServerSide

SearchWinDevelopment

Close