This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.io.EOFException between applet and servlet

 
may Lee
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic