This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Servlets and the fly likes Random communicaton....Servlet to Applet ??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Random communicaton....Servlet to Applet ???" Watch "Random communicaton....Servlet to Applet ???" New topic
Author

Random communicaton....Servlet to Applet ???

Kruger Brent
Greenhorn

Joined: Jan 05, 2001
Posts: 26
Hello all,
Unfortunately, I am stuck with a problem of sending info to the requesting applet as and when servlet wants to. Meaning that the
applet in its run() should continuosly wait for any incoming
messages from servlet. But what happens is the run() does not
block the program flow when it reaches statement....
String info = (String) ois.readObject()... as it normally does
when the communication is based on ServerSocket and socket
objects, but here the communication is based on URL and
URLConnection objects.
I succeed in sending request from applet to servlet using URL and
URLConnection objects and also in getting response from servlet
once but, as my run() is in while loop it throws IOException on
not getting further responses.
Any idea over this?
KB
[This message has been edited by Kruger Brent (edited January 19, 2001).]
Roshini Sridharan
Ranch Hand

Joined: Jan 16, 2001
Posts: 143

are u creating the object outside the loop/ inside, pls clarify.
If u are creating the ObjectInputStream object inside, try putting it before the loop.
Roshini
Kruger Brent
Greenhorn

Joined: Jan 05, 2001
Posts: 26
Thanks Roshini,
I am creating the ObjectInputStream object before the loop. And is it that for every request made by applet we have to create a new object of URL and URLConnection?
KB.
Roshini Sridharan
Ranch Hand

Joined: Jan 16, 2001
Posts: 143
No it's not required to create new URL & URLConnection object each and every time, then it creates a problem like socket already open.
RoshiniSridharan
Kruger Brent
Greenhorn

Joined: Jan 05, 2001
Posts: 26
Well then I am unable to make request for the 2nd time using the same ObjectOutputStream object. You mean if we use the same object to make a request to servlet it would again invoke the doGet() of the servlet?
 
Don't get me started about those stupid light bulbs.
 
subject: Random communicaton....Servlet to Applet ???