commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Qingtian Wang" <>
Subject fileupload newbie question
Date Tue, 06 Jul 2004 00:10:01 GMT

I've got this form in my JSP:

        <form action='/telescope/prototype/readExcel' enctype='multipart/form-data' method='post'>
            <tr><td>form field:</td><td><input type='text' size='10'
            <tr><td>Excel file to upload:</td><td><input type='file'
            <tr><td><input type='submit' /></td></tr>

In the processing servlet, I have:

~~~~~~~ Servlet ~~~~~~~

            InputStream is = request.getInputStream();
            InputStreamReader isReader = new InputStreamReader(is);
            BufferedReader bReader = new BufferedReader(isReader);
            String sOut = "";

            while ((sOut = bReader.readLine()) != null) {

		List fileItems = new DiskFileUpload().parseRequest(request);
		System.out.println("Number of file items -- " + fileItems.size());


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

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

my value
Number of file items -- 0



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

View raw message