Im using TomCat 4.1.12 (Standalone) on redhat linux 7.2 (kernel 2.4.7-10):

jsp:

<form action="jguru.jsp" enctype="MULTIPART/FORMDATA" method=post>
<input type="file" name="fileName" value="/home/seaver/txts/letter.txt"  />
........
<jsp:useBean id="xmlHandler" class="com.jguru.SimpleBean">
<jsp:setProperty name="xmlHandler" property="fileName" />
</jsp:useBean>
<%
xmlHandler.doUpload(request);
%>

bean:

blah blah..............

public void doUpload(HttpServletRequest request) throws IOException {
        ServletInputStream in = request.getInputStream();
        int len = request.getContentLength();
        byte[] line = new byte[len];
        PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter
            ("/home/seaver/Demo.out")));

        pw.print("Demo.out body\n");

        try {
            int offset = 0;
            do {
                int inputLen = in.readLine(line, offset, len-offset);
                if(inputLen <=0){
                    String msg = "read finished early - read "+
                        offset+" of "+len+" bytes (contentLength)";
                    throw new IOException(msg);
                } else {
                    pw.print(line);
                }
                    offset += inputLen;
            } while ((len-offset)> 0);
        }catch(IOException e){
            throw e;
        }

        pw.close();
    }

all i get, when I submit the file, is this error:

org.apache.jasper.JasperException: read finished early - read 0 of 60 bytes 
(contentLength)

which is programmed IN my bean, but the number of different ways ive tried 
to get the HTTP Request to print out to a file has not given me anymore than 
a -1, or even jumbled data.

i've read a lot about tomcat's inability to parse multipart, but what should 
I do?

S

"JC Rules"

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to