This example shows you, how to send data to a servlet from an applet and receive an answer. The servlet is an echo server, which simply sends back the string from the applet. The applet looks like this:
This is the complete source code: EchoServlet.java, EchoApplet.java, Tomcat's web.xml
All precompiled and tested with Tomcat: echo.zip. For installing, extract it under tomcat/webapps/echo and add to your tomcat/conf/server.xml the following line:
<Context path="/echo" docBase="echo" reloadable="true"/>
If you have installed Tomcat on your localhost, you can call the applet like
this: http://localhost:8080/echo/index.html