3. How would you communicate between applets and servlets ?

We can use the java.net.URLConnection and java.net.URL classes to open a standard HTTP connection and

tunnel” to a Web server. The server then passes this information to the servlet. 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. Applets can communicate with servlets using GET or POST methods.

The parameters can be passed between the applet and the servlet as name value pairs.

http://www.foo.com/servlet/TestServlet?LastName=Jones&FirstName=Joe).


Objects can also be passed between applet and servlet using object serialization. Objects are serialized to and

from the inputstream and outputstream of the connection respectively.


No comments:

Post a Comment