aspose file tools*
The moose likes Servlets and the fly likes passing object between applet and servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "passing object between applet and servlet" Watch "passing object between applet and servlet" New topic
Author

passing object between applet and servlet

may Lee
Ranch Hand

Joined: Nov 20, 2003
Posts: 68
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

Joined: Jun 13, 2000
Posts: 3340
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.


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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

Joined: Nov 20, 2003
Posts: 68
Thanks very much!
 
wood burning stoves
 
subject: passing object between applet and servlet