File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Unsolicited Responses Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Unsolicited Responses" Watch "Unsolicited Responses" New topic
Author

Unsolicited Responses

Doug Gschwind
Ranch Hand

Joined: Dec 17, 1998
Posts: 44
Suppose you have a web browser/applet running which you would like to receive unsolicited messages from the server side. e.g. Suppose the client side wishes to subscribe for and display event data when certain events are posted to an OMG CORBAservice Event Service implementation.
It does not appear that Servlets support this functional need very well due to the request-response paradigm.
I did however read about a couple of tricks which may or may not in fact help in this regard. One involves the use of a persistent connection. The other could be that the client side issues one request, where the servlet responds multiple times, but never actually closes the response object. What do you know about these two mechanisms?
What technological alternatives provide a more "intended" solution to this problem?
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20494
    ∞

I don't see a servlet helping here. I do see a socket connection from the applet to a server program (not a servlet). Over this full time connection, the server will send the occasional message.
This seems the most straightforward.

permaculture Wood Burning Stoves 2.0 - 4-DVD set
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
I agree with Paul here. One of the main things about the Applet specification is that despite all the sandbox limitations, applets are always allowed to make a socket connection to the originating host. It's a bit of a shame, but many applet writers inore this and try to make HTTP jump through hoops.
Don't be afraid of writing a server, either. There are plenty of examples around, and a simple server needn't be more than 50 lines of code.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
g2 bhai
Greenhorn

Joined: Jul 11, 2001
Posts: 2
Hi
Since the solution is to have an Applet to use for communication between the Server and the client.Can i have an invisible Applet..which will run in the background and only show messages to the client when the Server when the server wants the applet to display the messages.
thanks
g2
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952
    
  19

Correct. Http doesn't allow for "volunteering" info. However, an applet can poll the server and get the same net effect, subject to the polling overhead. To do a true "listen" (non-polled operation), you'd need to use a non-http I/O port, which could run you into the firewall.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unsolicited Responses
 
Similar Threads
How to do Server pushing?
JSP simple problem
yesno()
Automatically refresh datatable when Session Bean changes
Notifying user using JSF after the Asynchronous session bean method completes