This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Servlets and the fly likes URLConnection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "URLConnection" Watch "URLConnection" New topic


chris p

Joined: Oct 16, 2001
Posts: 6
hey guys,
I was wondering...
if you were to make a URLConnection from an applet to a servlet, is there any way to keep that connection alive as a bi-directional link between the two, or is the connection a one shot deal? If it is possible to keep the connection alive, how would the servlet get a reference to it?
also, if it is a one shot deal, is there any way to create a bi-directional connection between an applet and a servlet? (ie is there any way to make an applet and a servlet behave as a client and a server)?
thanks again!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17423

No, URLConnection assumes the HTTP protocol of one request, one response. For performance reasons a web server can keep a channel open to a client, but the HTTP protocol applies regardless.
You could do "client/server" by opening a general socket connection, but it won't work for general clients on the Internet because a lot of clients are behind firewalls that only allow http (and maybe ftp). For INTRAnet purposes you have more flexibility. Among other things, you can use RMI or CORBA to do remote procedure calls and let the sordid little details of networking take place out of sight.

An IDE is no substitute for an Intelligent Developer.
chris p

Joined: Oct 16, 2001
Posts: 6
I agree. Here's the link:
subject: URLConnection
jQuery in Action, 3rd edition