File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "Orielly Maultipart Request : unexpected end of part" Watch "Orielly Maultipart Request : unexpected end of part" New topic

Orielly Maultipart Request : unexpected end of part

Zulaikha Moidin

Joined: Mar 18, 2008
Posts: 2

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] unexpected end of part
at com.oreilly.servlet.multipart.PartInputStream.fill(
at com.oreilly.servlet.multipart.FilePart.write(
at com.oreilly.servlet.multipart.FilePart.writeTo(
at com.oreilly.servlet.MultipartRequest.(

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

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

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'); = '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>';

var hiddenForm = document.getElementById("hidden_form");

// attach the file to the hidden form and submit
// call server for updates on the status of file upload

maybe someone can figure out the problem
I agree. Here's the link:
subject: Orielly Maultipart Request : unexpected end of part
It's not a secret anymore!