Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 47601 invoked from network); 3 Dec 2003 18:32:16 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 3 Dec 2003 18:32:16 -0000 Received: (qmail 52019 invoked by uid 500); 3 Dec 2003 18:31:50 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 52003 invoked by uid 500); 3 Dec 2003 18:31:50 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 51985 invoked from network); 3 Dec 2003 18:31:49 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 3 Dec 2003 18:31:49 -0000 Received: (qmail 47571 invoked by uid 1339); 3 Dec 2003 18:32:10 -0000 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 3 Dec 2003 18:32:10 -0000 Date: Wed, 3 Dec 2003 10:32:10 -0800 (PST) From: Martin Cooper To: Jakarta Commons Users List Subject: Re: FileUpload parseRequest In-Reply-To: Message-ID: <20031203102922.N40587@minotaur.apache.org> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: localhost 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Wed, 3 Dec 2003, Parmley, Scott C. wrote: > Greetings. > > I am trying to use FileUpload 1.0 to handle multipart requests. I followed the HowTo on FileUpload. Everything seems to work ok until I get to parseRequest(request). No exception is thrown and the resulting list size is 0. Therefore, hasNext() (Iterator) fails from the get go. Is there something I am missing here? Seems odd. A couple of things to check: 1) Does it make any difference if you don't mess with the value before submitting the file? For example, don't use 'onclick', but just submit the form directly. 2) In what environment are you invoking this method? Are you sure that some other piece of code has not already parsed (and therefore consumed) the input stream before you try to process it? -- Martin Cooper > > Thanks in advance, > -Scott > > > Environment: JBoss+Jetty 3.2.1 > Windows 2k > JDK 1.4.2 > > > > HTML Sample: > > > > > Attachment Manager > > > > > > > > > > > > > > > > > > > >
Attachments
IssueTemplate.html
paradigm-logo.gif
> >
>
Upload: > > > > > >
>
> > > > > > Java Sample: > [...] > > public void writeUpload(HttpServletRequest request) { > try { > DiskFileUpload fbase = new DiskFileUpload(); > > fbase.setSizeMax(10000); > fbase.setSizeThreshold(10000); > fbase.setRepositoryPath(location); > > if(fbase.isMultipartContent(request)) { > System.out.println("IS MULITPART....HANDLING."); > List fitems = fbase.parseRequest(request); > > > > Iterator fit = fitems.iterator(); > String issueID = new String(); > String fileName = new String(); > > while(fit.hasNext()) { > FileItem f = (FileItem)fit.next(); > if(f.isFormField()) { > String a = f.getFieldName(); > > if(a.equals("issueID")) { > issueID = f.getString(); > System.out.println("IssueID: "+issueID); > } > else if(a.equals("fileName")) { > fileName = f.getString(); > System.out.println("FileName: "+fileName); > } > } > else { > System.out.println("Attachment Name: "+f.getName()); > System.out.println("Type: "+f.getContentType()); > f.write(new File(location+File.separator+issueID+File.separator+fileName)); > } > } > } > else { > System.out.println("NOT MULTIPART!"); > } > > } > catch(Exception e) { > e.printStackTrace(); > } > } > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org