Communication between applet and servlet Java Code

Posted on

                        Communication between applet and servlet Java Code

Today i will discuss about the communication between applet and servlet’s,  the most common problem faced by beginner’s during Java  development . So taking the applet as front end , our servlet at middle and database at back end most probably MYSQL.

Beginning at the applet end put the given below code in applet class outside paint function (must) . Change the  URL urlServlet = new URL(getCodeBase(), “points”) ,if your  servlet location is different than default location. You can send any object through this connection .just create the  object and send it through  oos.writeObject(your object) .

Communication between applet and servlet Java Code –Applet Code

Communication between applet and servlet Java Code-Servlet Code

Now moving to our servlet whose name is points in root folder of our workspace(Server folder apache). The code given below simply accept the string send by the applet and send it back to applet.

 

 

Source projectgeek.com