• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ObjectOutputStream problem

 
kelly goedert
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my applet on the init method I have:
try{
ObjectOutputStream outputToServlet = new ObjectOutputStream(con.getOutputStream());
outputToServlet.write(1);
outputToServlet.flush();
outputToServlet.close();
con.disconnect();
}
And in a servlet on the doGet method I have:
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

System.out.println("to no checar");
ObjectInputStream in = new ObjectInputStream(request.getInputStream());
int aux = in.read();
in.close();
System.out.println("" + aux);
}
And this doesn't work. The servlet seems not to be called. The strange thinsg is that if I try to send data from servlet to applet it works fine with the same ObjectInputStream and ObjectOutputStream. Why I can get this to work from applet to servlet??
 
Joe Ess
Bartender
Posts: 9337
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My wild guess (supposing you are using HTTP to contact your web server) is that, since HTTP is a request-response protocol, and your applet code merely sends a request then closes the connection, that the web server/servlet container considers the HTTP request canceled and never asks the servlet to respond. Try having your servlet respond with a simple "data received" message and have your applet read that message.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic