This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Orielly Maultipart Request : unexpected end of part Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Orielly Maultipart Request : unexpected end of part" Watch "Orielly Maultipart Request : unexpected end of part" New topic
Author

Orielly Maultipart Request : unexpected end of part

Zulaikha Moidin
Greenhorn

Joined: Mar 18, 2008
Posts: 2
Hi,

I am trying to upload files to my server using oriellys MultipartRequest.

I seem to get the following exception at random times

[2008-03-17 12:59:13,656] java.io.IOException: unexpected end of part
at com.oreilly.servlet.multipart.PartInputStream.fill(PartInputStream.java:100)
at com.oreilly.servlet.multipart.PartInputStream.read(PartInputStream.java:183)
at com.oreilly.servlet.multipart.PartInputStream.read(PartInputStream.java:156)
at com.oreilly.servlet.multipart.FilePart.write(FilePart.java:208)
at com.oreilly.servlet.multipart.FilePart.writeTo(FilePart.java:167)
at com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:266)

The code that causes this error is
MultipartRequest mReq;
try {
mReq = new MultipartRequest(request, FileUtil.getSharedTmpDir().toString(),
MAX_FILE_BYTE_SIZE, Encoding.STRING_ENCODING, RENAMER);
}

The real problem is that, the upload works sometimes and sometimes throws this error. It seem to throw error more often when I upload large files(>100K) but not always.

I am using Tomcat6.0/ apache

not much information in the oreilly faq site. I googled about this issue and found that it could be a AJP13 bug. I am not able to find how to fix this.
Any suggestion or help is greatly appreciated.
Zulaikha Moidin
Greenhorn

Joined: Mar 18, 2008
Posts: 2
some more info on the above issue.
I seem to get this more often in Firefox.

I submit the form via Javascript and not through form

=========

var theFile = document.getElementById(inpName);
var theDiv = document.createElement('div');
theDiv.style.display = 'none';
theDiv.innerHTML ='<iframe id="hidden_frame" name="hidden_frame" src=""></iframe>' +
'<form id="hidden_form" target="hidden_frame" action="../servlet/Ajax?rnd='+Math.random()+'&cmd=fileUpload" enctype="multipart/form-data" method="post"></form>';

document.body.appendChild(theDiv);
var hiddenForm = document.getElementById("hidden_form");
fileParent.removeChild(theFile);

// attach the file to the hidden form and submit
hiddenForm.appendChild(theFile);
hiddenForm.submit();
// call server for updates on the status of file upload

maybe someone can figure out the problem
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Orielly Maultipart Request : unexpected end of part
 
Similar Threads
file upload problem..urgent please
WAS 4.0.6 or IHS issue?
File uploading problem
Add a constructor in a subclass
problem while posting data