----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files.  Don't make us guess your problem!!!
----------------------------------------------------------------

Hello,

I have a servlet that can accept file uploads. Based on quite a bit of
logging & experimenting, I found that if the entire file is not read all at
once, the following exception is being thrown in my read loop:

      //open input stream from client to capture upload file
      inn = new DataInputStream(request.getInputStream());
        int formDataLength = request.getContentLength();
      int bytesRead = 0;
      int totalBytesRead = 0;
      int sizeCheck = 0;

        //2nd iteration here always causes exception below
       while (totalBytesRead < formDataLength) {
         bytesRead = inn.read(dataBytes, totalBytesRead, formDataLength);
         totalBytesRead += bytesRead;
         }

java.lang.IndexOutOfBoundsException
 at java.io.BufferedInputStream.read(BufferedInputStream.java, Compiled
Code)
 at
org.apache.jserv.JServConnection$JServInputStream.read(JServConnection.java,
Compiled Code)
 at java.io.DataInputStream.read(DataInputStream.java, Compiled Code)
 at
com.workwired.filevault.FileVaultServlet.catchUpload(FileVaultServlet.java,
Compiled Code)
 at java.lang.reflect.Method.invoke(Native Method)
 at
com.workwired.filevault.FileVaultServlet.processParameters(FileVaultServlet.
java, Compiled Code)
 at com.workwired.filevault.FileVaultServlet.doPost(FileVaultServlet.java,
Compiled Code)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java, Compiled Code)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java, Compiled Code)
 at org.apache.jserv.JServConnection.processRequest(JServConnection.java,
Compiled Code)
 at org.apache.jserv.JServConnection.run(JServConnection.java, Compiled
Code)
 at java.lang.Thread.run(Thread.java, Compiled Code)

My environment is: Sun Linux JDK 1.2.2(RC1), RedHat 6.0, JServ 1.0 and
Apache 1.3.6. BTW, I am porting my servlet from NT/Apache/Allaire JRun where
the problem does not exist.

Any thoughts appreciated!

Thanks,
Greg Purpura



--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to