A number of folks recently posted similar questions ...
I think things work better when you specify
"application/x-java-serialized-object" as
the content type of the data you are writing. In the code below, you're
using
"application/x-www-form-urlencoded", which definitely would not help.
- Fernando
Hi all!
I'm trying to do some application/applet to servlet communication where I
want to send an object to servlet.
My application code:
URL testServlet = new
URL("http://localhost:83/testApp/servlet/TestServlet");
URLConnection servletConnection = testServlet.openConnection
();
// inform the connection that we will send output and accept
input
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
// Don't use a cached version of URL connection.
servletConnection.setUseCaches(false);
servletConnection.setDefaultUseCaches(false);
// Specify the content type that we will send binary data
//servletConnection.setRequestProperty("Content-Type",
"application/octet-stream");
servletConnection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
// send the student object to the servlet using serialization
ObjectOutputStream outputToServlet = new
ObjectOutputStream(servletConnection.getOutputStream());
// serialize the object
outputToServlet.writeObject(new HelloObject(message));
outputToServlet.flush();
outputToServlet.close();
results in
Http10Interceptor: SocketException reading request, ignored
message on tomcat 3.3m4.
Any idea what I'm doing wrong ?
Any help will be appreciated.
Best regards,
Kovi