Hi,
I want to use an
applet to transfer a file on the client side to the a
servlet, whcih then stores the file on the server.
I tried to do it by passing a byte array as an object to the servlet (doPost), everything works fine with file sizes up to 34 MB. with file sizes over 34MB nthe writing to the servlet - ouputToServlet.writeObject(paramArray); - fails withoud any erroy or exception

(
is there any size limit with objectoutputstreams using the POST method???
i am using the following code:
applet on client side:
// read in file data into byte array "data"
File textFile = new File("c:\\test.data");
FileInputStream in = new FileInputStream(textFile);
int size = (int)textFile.length();
int read = 0;
byte data[] = new byte[size];
while (read > -1) {
read = (byte) in.read(data, read, size-read);
}
in.close();
//prepare an ArrayList with a
String object and the file data "data"
ArrayList paramArray.clear();
paramArray.add("action:upload");
paramArray.add(data);
//connect to servlet
String servletLocation = "my servlet address";
URL urlServlet = new URL(servletLocation);
con = urlServlet.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty("Content-Type", "application/x-java-serialized-object");
//output object to servlet
ObjectOutputStream ouputToServlet = new ObjectOutputStream(con.getOutputStream());
ouputToServlet.writeObject(paramArray); // fails when the data is larger than 34 MB!....)
ouputToServlet.flush();
ouputToServlet.close();
code of servlet in server side:
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ObjectInputStream inputFromApplet = null;
ArrayList paramArray = null;
response.setContentType("application/x-java-serialized-object");
inputFromApplet = new ObjectInputStream(request.getInputStream());
paramArray = (ArrayList) inputFromApplet.readObject();
if (paramArray.get(0).equals("action:upload")) {
FileOutputStream out = new FileOutputStream("c:\\uploaded.data");
out.write((byte[])paramArray.get(1));
out.close();
}
}
Does anyone know why only data with size smaller than 34MB is handled??
I am using JDK 1.4x and latest
JBOSS - version as EJB/servlet container.
Thanks for help!
Alex