persist connection between servlet and applet

I wrote a socket-based chat program and now I need to run it from behind the firewall and the best way to do this is to use a servlet to facilitate communication between the applet (client) and the serversocket. The problem is that I cannot persist the connection between the servlet and the client. Obviously I can open the connection...send a message and receive some output from the servlet but I cannot keep the connection open to continue to send/receive data. Does anyone know a good way to keep this connection going? I also do not want to use 'keep-alive' as it is very unstable and unreliable. Thanks in advance.

[630 byte] By [uberallesa] at [2007-11-26 16:37:05]
# 1
Can you write me the outline structure how to connect Applets and Servlets and run the application. One of my projects includes it...till now i didnt move ahead on that.....Thanks in advance for your hrlp.
pdnsrka at 2007-7-8 23:02:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

It's pretty simple to 'connect' an applet to a servlet. I use the term connect loosely since you're just post/get a message to the servlet the same way an html/jsp page POSTs to a servlet.

Here's a snippet of code from the applet the opens a connection to the servlet:

final static String servletCodeBase = "http://domain/servlet/ServletName";

PrintStream out = null;

URL url = new URL(servletCodeBase);

urlconn = url.openConnection();

urlconn.setDoOutput(true);

out = new PrintStream(urlconn.getOutputStream());

out.println("some text that is sent to the servlet");

hope this gets you started.

uberallesa at 2007-7-8 23:02:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
i willtry and come back to you thanks
pdnsrka at 2007-7-8 23:02:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...