This tip will show the way to push an applet from the servlet code. Following line of code can be added to the servlet for this purpose.

  out.println("<applet code=DemoappletName>" "</applet>")

  1. You must include the code base in the <applet> otherwise the applet class will not be located. So use the following line of code for the home directory.

  2.   out.println("<applet code=DemoappletName" "codebase='/'>" "</applet>"

  3. You must place the applet class along with the HTML documents. Otherwise if you keep the applet class in the directory, where the other java classes are usually kept, or with the servlet classes—then the client's browser is not able to locate the applet class.