commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Murat Birben <muratbir...@gmail.com>
Subject getItemIterator(request) returns false
Date Tue, 06 Jul 2010 10:08:21 GMT
Hi all,

I'm trying the stream api sample code in the site

       boolean isMultipart = ServletFileUpload.isMultipartContent(request);
>
>         if (isMultipart) {
>             try {
>                 // Create a new file upload handler
>                 ServletFileUpload upload = new ServletFileUpload();
>                 // Parse the request
>                 FileItemIterator iter = upload.getItemIterator(request);
>                 while (iter.hasNext()) {
>                     FileItemStream item = iter.next();
>                     String name = item.getFieldName();
>                     InputStream stream = item.openStream();
>                     if (item.isFormField()) {
>                         System.out.println("Form field " + name + " with
> value " + Streams.asString(stream) + " detected.");
>                     } else {
>                         System.out.println("File field " + name + " with
> file name " + item.getName() + " detected.");
>                         // Process the input stream
>                         //...
>                     }
>                 }
>
>             } catch (FileUploadException ex) {
>
> Logger.getLogger(ResourceUploadServlet.class.getName()).log(Level.SEVERE,
> null, ex);
>             }
>         }
>

but iter.hasNext() always return false. Here is the jsp code:

<form action="AServlet" method="POST"
>
>               enctype="multipart/form-data">
>                             <input type="file" name="Content" />
>
>                             Description : <input  type="text" name="Description" />
>
>                         <input type="submit" value="Submit" />
>
>         </form>
>
>
What is wrong with this stuff? Thanks...

Best,


-- 
Murat BIRBEN

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message