Servlet, writing data
I had a servlet which was running on my local windows machine using local host. We have managed to get hold of one of our colleagues 开发者_JS百科in America who is now hosting it on their Linux box so we can test the programme in a mimmicked real world environment for now.
However i seem to be getting an error, which i cant debug write now as my supervisor has gone for the day and i dont have access. We left it on the understanding i would do some investigation.
Just before he left i narrowed it down to these lines of code
file = File.createTempFile("temp", Long.toString(System.nanoTime()));
out.print("Managed to make temp file in trst_servlet");
FileWriter writer = new FileWriter(file);
ObjectOutputStream oos = xstream.createObjectOutputStream(writer, "ProcessedInformation");
oos.writeObject(returnedSearchData);
oos.flush();
oos.close();
out.print("object Persisted"); //PROGRAMME MAKES IT TO HERE
response.setContentLength((int)(file.length()));
FileInputStream in = new FileInputStream(file);
OutputStream ops = response.getOutputStream();
byte[]buf = new byte[1024];
int count = 0;
while((count = in.read(buf)) >= 0)
{
ops.write(buf, 0, count);
}
in.close();
ops.close();
}
catch(IOException ex)
//EXCEPTION CAUGHT HERE
I was wondering, does anyone have any idea if this is an issue maybe with buffer sizes on a Linux box, or writing large file sizes for example and then trying to send it back down the wire.
Essentially this java based servlet writes xml to my c# programme.
Thanks
What is the error? Does it work if you load the URL in the browser?
Possible problems:
Given that it was working previously on another box, now on a new box the file coud not be found because it is in a different relative location.
Worked on windows machine, but not on Linux? Did you use windows path separators in a path to the file? "path\to\file" instead of "path/to/file"?
You don't have Content-type set to "application/xml" and C# client rejects it for some reason. (Test it in a browser).
精彩评论