Hi,

I've got this form in my JSP:

        <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><input type='file' /></td></tr>
            <tr><td><input type='submit' /></td></tr>
        </table>
        </form>


In the processing servlet, I have:

~~~~~~~ Servlet ~~~~~~~
<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());

<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 ~~~~~~~
<snip>

-----------------------------20053262110829
Content-Disposition: form-data; name="formFieldName"

my value
-----------------------------20053262110829--
Number of file items -- 0

<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

Reply via email to