0

GWT を使用して、ハードディスク内のフォルダーの内容を示すウィンドウを開き、ファイルを 1 つ選択してダウンロードしたいと考えています。ファイルのアップロードの反対だとしましょう。試しWindow.open("E:\\outil pfe bfi\\jboss-as-7.1.1.Final\\standalone\\deployments\\uploaded", "_blank", null); てみましたが、空白のウィンドウしか開きません。サーバー側では、ファイルを確実にダウンロードするサーブレットを作成しました。

public class DownloadDiskImpl extends HttpServlet {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    // TODO Auto-generated method stub
    super.doGet(req, resp);
}

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    String fileName = (String) req.getSession().getAttribute("fileName");


    InputStream in = null;
    OutputStream out = resp.getOutputStream();

    FileInputStream fIn = new FileInputStream(fileName);
    byte[] buffer = new byte[4096];
    int length;
    while ((length = in.read(buffer)) > 0){
        out.write(buffer, 0, length);
    }
    in.close();
    out.flush();

}

}

そして、次にどうすればいいのかわからない。そうする可能性はありますか?注意: パス:E:\\outil pfe bfi\\jboss-as-7.1.1.Final\\standalone\\deployments\\uploadedは、いくつかのファイルをアップロードしたサーバーの場所の下にあるフォルダーであり、ボタンをクリックしてダウンロードしたいことを忘れています。

4

0 に答える 0