Thanks so much, Tatu! I tried and that is indeed the cause of the problem. Cheers, Qingtian
> -----Original Message----- > From: Tatu Vanhanen [mailto:[EMAIL PROTECTED] > Sent: Tuesday, July 06, 2004 12:21 AM > To: Jakarta Commons Users List > Subject: RE: fileupload newbie question > > > The request's inputstream (or reader) can be consumed only > once. So because you have already used it, there's not much > left for the DiskFileUpload. Try parsing the request with > FileUpload without the code that outputs the request to System.out. > > - Tatu V. > > > -----Original Message----- > > From: Qingtian Wang [mailto:[EMAIL PROTECTED] > > Sent: 6. heinÃkuuta 2004 3:10 > > To: [EMAIL PROTECTED] > > Subject: fileupload newbie question > > > > > > Hi, > > > > I've got this form in my JSP: > > > > <DEFANGED_form action='/telescope/prototype/readExcel' > > enctype='multipart/form-data' method='post'> > > <table> > > <tr><td>form field:</td><td><input type='text' > > size='10' name='formFieldName'/></td></tr> > > <tr><td>Excel file to upload:</td><td><DEFANGED_input > > type='file' /></td></tr> > > <tr><td><DEFANGED_input type='submit' /></td></tr> > > </table> > > </DEFANGED_form> > > > > > > In the processing servlet, I have: > > > > ~~~~~~~ Servlet ~~~~~~~ > > <DEFANGED_snip> > > > > InputStream is = request.getInputStream(); > > InputStreamReader isReader = new InputStreamReader(is); > > BufferedReader bReader = new BufferedReader(isReader); > > String sOut = ""; > > > > while ((sOut = bReader.readLine()) != null) { > > System.out.println(sOut); > > } > > > > List fileItems = new > DiskFileUpload().parseRequest(request); > > System.out.println("Number of file items -- " + > > fileItems.size()); > > > > <DEFANGED_snip> > > ~~~~~~~ > > > > With that servlet, I always get "0" printed out as the size of > > the fileItems while I did enter the first text field and the > > second file to upload. And if I print out the HttpServletRequest > > "request" out of its InputStream, it does show the first text > > field, both name and the value I entered; but for the second file > > upload, it only shows an id-like line that looks like this: > > > > ~~~~~~~ output ~~~~~~~ > > <DEFANGED_snip> > > > > -----------------------------20053262110829 > > Content-Disposition: form-data; name="formFieldName" > > > > my value > > -----------------------------20053262110829-- > > Number of file items -- 0 > > > > <DEFANGED_snip> > > > > ~~~~~~~ > > > > What puzzles me here is that even if the second input, which the > > file upload part, didn't work out, the size of the "fileItems" > > still shouldn't be "0" because the request input stream clearly > > show that the first input, which is the text form-field input, is > > being successfully passed to the servlet. In that case, the > > parseRequest() method should at least return 1 item in the list > > of FileItems. > > > > Any ideas? > > > > Thanks very much for your help! > > Qingtian Wang > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
