• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing object between applet and servlet

 
may Lee
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Applet on Apache web server sends the object with some parameters to servlet,then servlet supported by tomcat passes back the object with changed parameters. The interesting is: in applet side, it is not working if I sending/getting object can not be put in two try{}(see the attached list 1). It is working when I put then in one try{}(see the attached list 2). Don't why?

List 1:

List 2


--Added code tags and formatted for easy reading- Carl
[ June 09, 2004: Message edited by: Carl Trusiak ]
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gee, in Listing 1, you have TWO URLConnections, one you write the object to and the other (Which by the way has NOTHING to do with the first) you are trying to read an Object off of. You can do this in 2 try blocks but, you need to use the same connection objecct in both:
List 3

There really is no reason to split these out like this. What will happen, if you get an exception in the first block, you will also get an exception in the second.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also NEVER close the connection after sending to the servlet, just flush() the stream. Calling toServlet.close(); will close the whole connection so don't do it until the response has been received.
Bill
 
may Lee
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic