File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 16537

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.

Customer surveys are for companies who didn't pay proper attention to begin with.
chris p

Joined: Oct 16, 2001
Posts: 6
I agree. Here's the link:
subject: URLConnection