Applet Tag


An applet is loaded from an applet tag included within an HTML page.  The browser handles it similarly to the way it handles an image.  That is, the page is loaded and the HTML parsed.  the browser then goes back to the server to bring in embedded objects referenced in the HTML.

The applet tag must include references to both the applet, itself, and to the location or codebase where it and its supporting classes are stored.  An example of this second reference would be a path to the directory structure described above.

Below is an example of such an applet tag:

<jsp:useBean id="sessionBean" scope="session" 
class="jbs.abapplet.databean.SessionBean"/>

<%
String sessionId = sessionBean.getSessionID();
%>
<APPLET 
CODE = "jbs/abapplet/applet/AppletAB.class" 
CODEBASE = "/ABApplet/abapplet/applets" 
WIDTH = "600" HEIGHT = "800"
JSESSIONID = "<%= sessionId%>" 
scriptable=false />

The project name, ABApplet in this case, will, of course, need to be changed to the appropriate context, such as jbs.

In applications where the applet is loaded from the same context as the preceding HTML or JSP pages, the tag will not need to include the JSESSIONID; this code is shown here as additional material for those examples in which it is needed.

If the applet is complex, meaning includes a number of supporting classes or requires external library or jar files, a common practice is to include an archive reference within the applet tag.  This archive reference may include both external libraries as well as an archive collection of the applet and its support classes.  an example of such a tag is shown, below:

<APPLET  
CODE = projectmanager.web.applet.applet.Applet
CODEBASE = /ProjectManagerWeb/applets/
ARCHIVE = applet.jar,databeans.jar,jdom.jar,xerces.jar
WIDTH = 500 HEIGHT = 560 >
<PARAM name="DOCID" value="<%=docId%>" > 
<PARAM name="DOCTYPE" value="<%=docType%>" > 
</APPLET>

 

In this example, the primary applet class is identified in its fully qualified form.  The codebase provides the path where all of the applet resources may be found.  And the archive identifies all of the various jar files required for this applet.  Also shown are two parameters and their values that are made available to the applet through the applet tag.