I try to send a number of userdefined
strings as a serialized object from
an applet to a servlet (I use Jigsaw 2.0.2
as a server on my localhost).
This is my code for sending the object
from the applet:
log("Connecting to
servlet...");
URL StakoDBservlet = new URL( urlStr); URLConnection servletConnection = StakoDBservlet.openConnection(); log("Connected"); servletConnection.setDoInput(true); servletConnection.setDoOutput(true); servletConnection.setUseCaches (false); servletConnection.setRequestProperty("Content-Type", "application/octet-stream"); sendCustomerToServlet(servletConnection, theCustomer); servletConnection.connect(); The method
sendCustomerToServlet(servletConnection, theCustomer);
// theCustomer is the serialized object looks like this:
protected void
sendCustomerToServlet(URLConnection servletConnection, StakoReg
theCustomer)
{ ObjectOutputStream outputToServlet = null;
try
{ log("Sending the customer to the servlet..."); outputToServlet = new ObjectOutputStream(servletConnection.getOutputStream());
outputToServlet.writeObject(theCustomer);
outputToServlet.flush();
outputToServlet.close(); log("Complete."); } catch (IOException e) { log(e.toString()); } } I log "Complete" but then I get
a java.net socketException
with the message 'Unexpected end of file
from server'.
Please advise.
-dan |
- Re: java.net.socketException Ragna-Lena&Dan
- Re: java.net.socketException Craig R. McClanahan