File Upload using MultipartRequest.

Although file gets uploaded successfully, I get the following WARNING message in my log file when ran on NT/2000 which is okay.

The message says:

"One of the getParameter family of methods called after reading from the ServletInputStream, not merging post parameters".

But when I run the same code on UNIX it gives me an ERROR message. (message same as above). That crahes my JSP in the UNIX enviro. Any idea why does this happen? pl. let me know ASAP.

My production environment is UNIX based.

Here goes the code that I wrote.

<form name="myform" method="post" action="upload_file.jsp" enctype="multipart/form-data">

<table border="1" bordercolor="white" cellspacing="1" cellpadding="2" align="center" bgcolor="#c9dced">

<% for (int i=1; i<=5; i++) { %>

<tr>

<td>

<font face="Arial, Helvetica, sans-serif" size="1">Document</font>

<input type="file" name=<%="\"documentNameTF" + i + "\""%> maxlength="100" size="30">

</td>

</tr>

<% } // end for %>

<tr>

<td colspan="2" align="center">

<input type="button" name="saveBTN" value="Add Documents" onClick="document.myform.submit()">

</td>

</tr>

</table>

</form>

file2: upload_file.jsp

<%if (request.getContentType().startsWith("multipart/form-data",0)) {

com.oreilly.servlet.MultipartRequest multi = new com.oreilly.servlet.MultipartRequest(request, path ,MAX_FILE_SIZE);

/* Retrieve Parameters from multi */

for (int i=1; i<=5; i++) {

if (multi.getFilesystemName("documentNameTF" + i) != null) {

slDocUrl = multi.getFilesystemName("documentNameTF1");

} else {

slDocUrl = "";

}

} // end for 1-5

multi = null;

}

%>

Thanks,

Rakesh.

[1954 byte] By [rakeshahuja] at [2007-9-26 2:38:27]
# 1
That is easy. You have to write servlet to handle your request. Because JSP opens the input stream as "non-multipart-request".RegardsJan
pernica at 2007-6-29 10:09:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Actually, I think the best way to upload mutiple stuff is using ZipOutputStream. do some reach on "java.util.zip", you will find that it's much better than using multipart component.Good luck
stanley.lam@usa.net at 2007-6-29 10:09:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...