Bill, the file size in the applet is sent to the servlet via request parameter...
long file_size_long = file.length();
String file_size = String.valueOf(file_size_long);
...
URL url = new URL("http://test_server/test_app/Servlet?file_size="+file_size);
...
(still inside the applet, the file is read and written into the ouputstream from the servlet)
...
byte[] ByteArray = new byte[(int)file_size_long];
int numBytes = inputFileStream.read(ByteArray);
int offset = 0;
while (numBytes >= 0) {
System.out.println("numBytes is " + numBytes);
os.write(ByteArray, offset, numBytes);
numBytes = inputFileStream.read(ByteArray);
offset = offset + numBytes;
}
when the applet completes, the last line I see written on the console is "numBytes is -1", indicating all of ByteArray, of length file_size_long, was written to the servlet.
Does this look about right? I think setting the request header would accomplish the same thing and yield the same result...inexplicable truncation to 5520 bytes between applet and servlet...
As far as available() in the servlet, I put that in to see how much was available to the servlet. I was hoping to see the full file size, but it always yields 5520, unless the file is < 5520 bytes, then it shows the entire size. As stated above, I am trying to use the file_size request parameter as the imgFileSize variable...
from the servlet:
String file_size_parameter = request.getParameter("file_size");
long imgFileSize = Long.parseLong(file_size_parameter);
I am given some pause about this available() method. When the servlet reads the inputstream, how could it ever be guaranteed to read all the bytes in a stream at any given time if available() can return anything less than the full number of bytes?
Thank you very much again for hanging around with this or whatever.
[ December 13, 2005: Message edited by: Tom Griffith ]