<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Sealyu

    --- 博客已遷移至: http://www.sealyu.com/blog

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      618 隨筆 :: 87 文章 :: 225 評論 :: 0 Trackbacks
    Per some requests for the File Download opposite of File Upload.

    On the server side I implemented the doGet method of the HttpServlet class. I grab the raw data from the database and set it into the response (with the appropriate response type):

    BufferedOutputStream output = null;
    try {
    RawAttachmentItem attachment = attachmentFileDao.retrieveContents(fileid);
    ByteArrayInputStream input = new ByteArrayInputStream(attachment.getContents());
    int contentLength = input.available();

    resp.reset();
    resp.setContentType("application/octet-stream");
    resp.setContentLength(contentLength);
    resp.setHeader("Content-disposition", "attachment; filename=""" + attachment.getFilename()
    + """");
    output = new BufferedOutputStream(resp.getOutputStream());
    for(int data; (data=input.read()) != -1;) {
    output.write(data);
    }
    output.flush();
    }
    catch (IOException e) {

    e.printStackTrace();
    }
    finally {
    close(output);
    }
    On the client side, you simple create a new iFrame with its 'src' attribute set to the servlet url for downloading the file:

    boolean frameExists = (RootPanel.get("downloadiframe") != null);
    if(frameExists) {
    Widget widgetFrame = (Widget)RootPanel.get("downloadiframe");
    widgetFrame.removeFromParent();
    }

    NamedFrame frame = new NamedFrame("downloadiframe");
    frame.setUrl(GWT.getModuleBaseURL()
    + "/attachmentHandler?action=dl&fileid="
    + model.getFileId());
    frame.setVisible(false);

    RootPanel.get().add(frame);
    When the file gets sent back to the iFrame, the browser will treat it as a file download and prompt you to do something with it (open, save, cancel, etc).

    If anyone has questions or requires more detail, please do not hesitate to ask!!
    posted on 2010-02-01 21:21 seal 閱讀(619) 評論(0)  編輯  收藏 所屬分類: GWT
    主站蜘蛛池模板: 国产精品免费视频一区| 免费观看AV片在线播放| 亚洲综合精品第一页| 免费在线看v网址| 丝袜捆绑调教视频免费区| 日韩亚洲Av人人夜夜澡人人爽| 国产h肉在线视频免费观看| 国产成人精品免费大全| 久久亚洲精品无码AV红樱桃| 亚洲精品国产高清嫩草影院| 永久免费av无码网站大全| 曰批全过程免费视频播放网站 | 亚洲熟妇av一区二区三区| 久久午夜夜伦鲁鲁片免费无码| 亚洲国产成人九九综合| 亚洲av日韩av天堂影片精品| JLZZJLZZ亚洲乱熟无码| 88xx成人永久免费观看| 亚洲精品久久无码av片俺去也| 亚洲色欲或者高潮影院| 久久青青草原亚洲AV无码麻豆| 国产偷窥女洗浴在线观看亚洲| 四只虎免费永久观看| 暖暖在线视频免费视频| 中文字幕手机在线免费看电影| 菠萝菠萝蜜在线免费视频| 久久久久久久久亚洲| 成人午夜亚洲精品无码网站| 亚洲国产成人乱码精品女人久久久不卡| 成人免费一区二区三区在线观看| 日韩亚洲国产高清免费视频| 在线观看免费视频资源| **一级一级毛片免费观看| 18禁无遮挡无码国产免费网站| 久久一本岛在免费线观看2020| 叮咚影视在线观看免费完整版| 999zyz**站免费毛片| 亚洲av无一区二区三区| 亚洲精品第五页中文字幕| 久久精品国产亚洲AV电影| 亚洲精品福利在线观看|