Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem on file upload

843840Jun 28 2010 — edited Jul 5 2010
Hi,

I use this to upload a file and it works on all servers except on one, and I don't know why (its a Tomcat running on a HP-UX server):

<form action="./upload_file_test.jsp" ENCTYPE="multipart/form-data" method="post" name="dataform" onsubmit="javascript:return Juge(this);">

And then:

SmartUpload smartUpload = new SmartUpload();

smartUpload.initialize(pageContext);
smartUpload.upload();

....

The smartUpload.upload() takes ages to finish and returns no error. But after, when I try to do:

com.jspsmart.upload.File myFile = smartUpload.getFiles().getFile(0);

It throws an exception: "Files' name is invalid or does not exist"

I've tried changing the code and not use the smartUpload lib, like this:

String contentType = request.getContentType();
if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
DataInputStream in = new DataInputStream(request.
getInputStream());



int formDataLength = request.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
int available = in.available();

while (totalBytesRead < formDataLength) {
byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
totalBytesRead += byteRead;
}

But, if I print the totalBytesRead and the formDataLength I get always totalBytesRead = 2147483647, when the formDataLength is much smaller.

And also, this takes a lot of time.

I've already searched for days for a solution, but I can't find one. Is it a server issue or something else (as I said this works on all other servers, all of them also HP-UX running Tomcat)?

Thanks,
Fernando
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 2 2010
Added on Jun 28 2010
14 comments
249 views