Forward multipart zip file
843840Feb 26 2003 — edited Mar 19 2008After many, many sleepless hours I come humbly before you to see if you can help. I have a client posting a zip file to a servlet. This part is fine but now I must send/forward/repost to a different servlet on a remote server. I understand that a normal forward will not work for a multipart and that sending as an object will not work due to the ZipFile class not being serializable. So I am trying this:
<pre>
URL remoteUrl = new URL(redirectUrl);
URLConnection remoteCon = remoteUrl.openConnection();
remoteCon.setDoOutput(true);
remoteCon.setDoInput(true);
ByteArrayOutputStream byteStream3 = new ByteArrayOutputStream(100000000);
BufferedReader in = new BufferedReader(new FileReader(outFile));
int r = 0;
while(in.ready())
{
r = in.read();
byteStream3.write(r);
}
String lengthString3 = String.valueOf(byteStream2.size());
remoteCon.setRequestProperty("Content-Length",lengthString3);
remoteCon.setRequestProperty("Content-Type","multipart/form-data");
remoteCon.setRequestProperty("Cookie", thisCookie);
byteStream3.writeTo(remoteCon.getOutputStream());
byteStream3.flush();
byteStream3.close();
remoteCon.connect();
</pre>
This will read the file and send an output stream to the next servlet. But for some reason the connection never gets made. The waiting servlet never gets a request made to it.
Anything noticeable with this code?
Are there any other potential options? Maybe pack the bytes into an xml file and send that way?
Thanks,