Return-Path: X-Original-To: apmail-commons-user-archive@www.apache.org Delivered-To: apmail-commons-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0673810CD6 for ; Tue, 30 Jul 2013 01:47:24 +0000 (UTC) Received: (qmail 64294 invoked by uid 500); 30 Jul 2013 01:47:22 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 64211 invoked by uid 500); 30 Jul 2013 01:47:22 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 64203 invoked by uid 99); 30 Jul 2013 01:47:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Jul 2013 01:47:22 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of mihaisheng@163.com designates 220.181.13.99 as permitted sender) Received: from [220.181.13.99] (HELO m13-99.163.com) (220.181.13.99) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Jul 2013 01:47:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Received:Date:From:To:Subject:Content-Type: MIME-Version:Message-ID; bh=YFb0tljbEEvrcnJX2nVLsPvNtxhne6Wg6HMk UV8pAnQ=; b=oc6lvpbZGsklYxQm/kSMn9McN4N4phbUtPDF/v60sobUd0w+m9Ps 1Jeg3fPsGT+AYTmyB6HZaZzflpRYyuZDaatA7MriL0IT5ShtzrvBniUWjaicZz0q 3KN0GZ0L8hzODK7aEICt90DQlw0uqiKvyqTm6xMPnJDxgkWHg7Tlv9k= Received: from mihaisheng$163.com ( [124.117.241.71] ) by ajax-webmail-wmsvr99 (Coremail) ; Tue, 30 Jul 2013 09:46:51 +0800 (CST) X-Originating-IP: [124.117.241.71] Date: Tue, 30 Jul 2013 09:46:51 +0800 (CST) From: =?GBK?B?yq7I/cDJ?= To: user@commons.apache.org Subject: [fileupload]how to get progress stats from diffrent request. X-Priority: 3 X-Mailer: Coremail Webmail Server Version SP_ntes V3.5 build 20130709(22708.5479.5480) Copyright (c) 2002-2013 www.mailtech.cn 163com X-CM-CTRLDATA: LF63lmZvb3Rlcl9odG09MzM2Mzo4MQ== Content-Type: multipart/alternative; boundary="----=_Part_312076_1620963058.1375148811515" MIME-Version: 1.0 Message-ID: <27d23839.15080.1402d41a4fb.Coremail.mihaisheng@163.com> X-CM-TRANSID: Y8GowAC3y+wLG_dRByobAA--.3373W X-CM-SenderInfo: 5plktxxvkh0wi6rwjhhfrp/1tbiTgpqxFEAGGcC9wABsw X-Coremail-Antispam: 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU== X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_312076_1620963058.1375148811515 Content-Type: text/plain; charset=GBK Content-Transfer-Encoding: 7bit if i upload only one file,i save the percent stats to session,i can get the currect stats from ProgressListener. if i upload two file f1,f2 in same session,but diffrent request.i cant distinguish the two stats. to solve this problem, 1.i add a text field named "key" to distinguish two form action. 2.pass value of "key" to ProgressListener. for example: i will post in diffrent request: ----------
----------
i define my ProgressListener: public class UploadPro implements ProgressListener { private HttpServletRequest request; private String keyi; private DecimalFormat df = new DecimalFormat("#00.0"); //"#00.0" public UploadPro(HttpServletRequest request,String key){ this.request = request; this.keyi=keyi; } @Override public void update(long bytesRead, long bytesTotal, int items) { double percent= (double)bytesRead*100/(double)bytesTotal; System.out.println("percent :"+df.format(percent)); request.getSession().setAttribute("UPLOAD_PERCENTAGE_"+key, df.format(percent)); } } thus,the diffrent progress stats saved in diffrent session variable("UPLOAD_PERCENTAGE_"+key). to pass key value to ProgressListener,i must get value of parameter "key" before setProgressListener. my code write like this: ... List fileItems = upload.parseRequest(request); FileItem key=fileItems.get(0); upload.setProgressListener(new UploadPro(request,key.getString)); ... i run the project,i find ProgressListener do not work.and no exception message printed. so,i find ProgressListener not work if method setProgressListener called after method parseRequest. if setProgressListener before parseRequest,the code run correct,but i cant get parameter value. so, how to get progress stats from diffrent request(same session)???? thanks very much!!! ------=_Part_312076_1620963058.1375148811515--