Adding Applets to a Web Module

See Also

This topic describes how to do the following:

To add a simple applet to a web module

  1. Create a directory outside of the web module (that is, not in the web module's root directory or its subdirectories) for the applet source files.
  2. Place your applet classes and client-side helper classes in this source directory.
  3. Package the classes into a JAR file.
  4. Place the JAR file in a subdirectory of the web module's root directory other than the WEB-INF subdirectory. For example, create a subdirectory named applet and put the JAR file in this directory.
  5. In the applicable HTML and JSP pages, use the <applet/> tag with the codebase, archive, and code attributes to declare the applet and its classes.

To add an applet that shares classes with servlets to a web module:

  1. Create a directory outside of the web module (that is, not in the web module's root directory or its subdirectories) for the client-only applet classes, and put the source code for those classes in the directory.
  2. Create a separate directory outside of the web module for the shared classes and put the source code for those classes in the directory.
  3. Package the directory that has the shared classes into a JAR file and place it in the WEB-INF/lib directory.
  4. Package both the client-only classes and the shared classes into a JAR file and place the JAR file in a subdirectory of the web module's root directory other than the WEB-INF subdirectory. For example, create a subdirectory named applet and place the JAR file in this directory.
  5. In the applicable HTML and JSP pages, use the <applet/> tag with the codebase, archive, and code attributes to declare the applet and its classes.
  6. Put the source code for the servlet classes in the WEB-INF/classes directory.
See Also
Using JAR Files in Web Modules
Where to Put Web Module Files
About Creating Web Modules

Legal Notices