How can my applet or application communicate with my servlet?
It’s pretty straightforward. You can use the java.net.URLConnection and java.net.URL classes to open a standard HTTP connection to the web server. The server then passes this information to the servlet in the normal way. Basically, the applet pretends to be a web browser, and the servlet doesn’t know the difference. As far as the servlet is concerned, the applet is just another HTTP client. Of course, you can write a servlet that is meant to be called only by your applet, in which case it *does* know the difference. You can also open a ServerSocket on a custom TCP port, and have your applet open a Socket connection. You must then design and implement a custom socket-level protocol to handle the communication. This is how you could write, e.g., a Chat applet communicating with a servlet. In general, a custom protocol requires more work than HTTP, but is more flexible. However, custom protocols have a harder time getting through firewalls.