I have an applet that communicates with a servlet using Http (Not sockets). Currently, each instance of the applet (i.e. when each applet is run by a different client on a different computer), all the instances communicate with the same servlet. What I want is that each instance of the applet communicate with different instances of the same servlet. Is this possible?
I have an applet that communicates with a servlet using Http (Not sockets). Currently,
Share
You don’t want to have different instances of the same servlet in webapp’s lifetime. The normal practice is to use the
HttpSessionto distinguish between clients. You need to pass theHttpSession#getId()as parameter to the applet in question:Then, in the Applet connect the Servlet as follows:
Here
servleturlobviously should match servlet’surl-patterninweb.xml. You can alternatively also set aCookierequest header usingURLConnection.setRequestProperty().Finally, in the Servlet, to get and store client specific data, do as follows:
Hope this helps.