Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 85959 invoked from network); 20 Nov 2007 13:57:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Nov 2007 13:57:13 -0000 Received: (qmail 33789 invoked by uid 500); 20 Nov 2007 13:56:55 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 33741 invoked by uid 500); 20 Nov 2007 13:56:55 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 33732 invoked by uid 99); 20 Nov 2007 13:56:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Nov 2007 05:56:55 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [61.246.161.66] (HELO lxsrv.metalogic.com) (61.246.161.66) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Nov 2007 13:56:45 +0000 Received: from ws120 (ws120.metalogic.com [10.0.0.120]) by lxsrv.metalogic.com (8.12.8/8.12.8) with SMTP id lAKDv2TJ014623 for ; Tue, 20 Nov 2007 19:27:02 +0530 Message-ID: <003301c82b7d$23f27de0$7800000a@metalogicsystems.com> From: "shyamal" To: "Jakarta Commons Users List" References: <4742A914.6090408@IRISA.fr> <1195556432.2403.14.camel@localhost> <4742E017.6090105@IRISA.fr> Subject: Problem parseRequest with commons fileupload Date: Tue, 20 Nov 2007 19:26:25 +0530 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Checked: Checked by ClamAV on apache.org Hi, I am trying to upload a small text file using commons/fileupload 1.2. I am using NetBeans 5.5.1 with Bundled Tomcat 5.5.17. Here is the HTML code: Upload Page The java code is here: public class ourUpload extends HttpServlet { /** Processes requests for both HTTP GET and POST methods. * @param request servlet request * @param response servlet response */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); org.apache.commons.fileupload.disk.DiskFileItemFactory factory = new org.apache.commons.fileupload.disk.DiskFileItemFactory(); // maximum size that will be stored in memory factory.setSizeThreshold(4096); // the location for saving data that is larger than getSizeThreshold() factory.setRepository(new File("/tmp")); org.apache.commons.fileupload.servlet.ServletFileUpload upload=null; List fileItems = null; try { upload = new org.apache.commons.fileupload.servlet.ServletFileUpload(factory); // maximum size before a FileUploadException will be thrown upload.setSizeMax(1000000); fileItems = upload.parseRequest(request); } catch(Exception e) { e.printStackTrace(); } if (fileItems.size()==0) { out.println("Couldnot upload"); return; } Iterator i = fileItems.iterator(); String comment = ((FileItem)i.next()).getString(); FileItem fi = (FileItem)i.next(); // filename on the client String fileName = fi.getName(); fi.write(new File("/www/uploads/", fileName)); out.close(); } However, parseRequest is always returning a list with 0 items. I am not using struts or any request wrappers. Please Help!!! Thanks a lot in advance Shyamal --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org