aspose file tools*
The moose likes Servlets and the fly likes java.io.EOFException between applet and servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "java.io.EOFException between applet and servlet" Watch "java.io.EOFException between applet and servlet" New topic
Author

java.io.EOFException between applet and servlet

may Lee
Ranch Hand

Joined: Nov 20, 2003
Posts: 68
I use the following code to pass an object from applet to servlet, then receive another object from servlet to applet. Got the
java.io.EOFException error.
It is Signals that an end of file or end of stream has been reached unexpectedly during input. What could be the reason?

datato=new dataToservlet(year,month,day,hour,minute,timelength);
datafrom=new dataFromservlet(area,channelnum);

try{
URL url=new URL(servletPath);
URLConnection conn=url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.setDefaultUseCaches(false);
/****send object from applet to servlet******************/
conn.setRequestProperty("Content-Type","application/octet-stream");
ObjectOutputStream toServlet=new ObjectOutputStream(conn.getOutputStream());
toServlet.writeObject(datato);
toServlet.flush();
//toServlet.close();
/****get object df from servlet*********/
ObjectInputStream fromServlet=new ObjectInputStream(conn.getInputStream());
datafrom=(dataFromservlet)fromServlet.readObject();
}catch(Exception e){appleterrormessage=e.toString();appleterror=true;}
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: java.io.EOFException between applet and servlet