loading an applet in tomcat 4.x
843807Oct 22 2002 — edited Oct 23 2002Hi,
I have been reading the forums for a while trying to find an explanation to the problem I am having with no success.
The problem is that I have an applet that has a dynamic number of parameters. The number of parameters is determined by the contents of an application bean which is part of the environment.
The problem is that I can't get the applet to work using the <applet> tag. It seems that no matter what I set the codebase parameter to, I always get the dreaded "ClassDefNotFound Exception: FacilityApplet" in IE 6.0 or "ClassFormatError: Bad Major Version Number" exception in Netscape 4.79.
I am using JDK 1.4_0_01 and Tomcat 4.1.12 and my application (oam), context is organized as follows:
webapps/
oam
WEB-INF
classes
lib
applets
facility
jsp
html
index.html
I have jarred the applet into a file called FacilityApplet.jar and stored it into the oam/applets/facility directory. The contents of the jar file follows:
META-INF/
META-INF/MANIFEST.MF
FacilityApplet.class
common/DataEvent.class
common/Facility.class
common/Link.class
DialogBox/
DialogBox/DialogBox$CloseDialog.class
DialogBox/DialogBox$CloseWindow.class
DialogBox/DialogBox.class
The following is the contents of my jsp page that attempts to load the applet.
<html>
<head>
<!-- Ensure the HTTP Server Does Not Save this Page in Cache -->
<meta HTTP-EQUIV=Pragma CONTENT=no-cache >
<title> Status Page </title>
</head>
<%@ page import="javaBeans.SettingsBean" %>
<jsp:useBean id="settings" class="SettingsBean" scope="application" />
<body BGCOLOR="honeydew" LINK="Blue" TEXT="black" VLINK="Red">
<h1>
Application Status
</h1>
<%
// Make sure we have a good bean to work with
if (settings.getTotalFacilities() != 0) {
%>
<applet
archive="FacilityApplet.jar"
codebase="http://localhost:8080/oam/applets/facility"
code="FacilityApplet.class"
width="300" height="150" >
<param name="PORT" value="8939" >
<%
for (int i = 0;i < settings.getTotalFacilities();i++) {
%>
<param name="FAC_<%= i %>" value="<%= settings.getFacilityName(i) %>">
<param name="STATE_<%= i %>"
value="<%= settings.getFacility(i).getState() %>">
<% } %>
</applet>
<% }
else {
%>
<h2 align="center"> No Facilities to Display </h2>
<% } %>
</body>
</html>
Here are the values for codebase that I have tried so far:
codebase="<%= request.getContextPath() %>/applets/facility"
codebase="http:localhost:8080/oam/applets/facility"
codebase="../applets/facility"
I also expanded the jar file under the applets/facility directory with the same results. I also copied all the class files in the same directory as my jsp file, codebase="facility", with the same results.
Now, if I use the <jsp:plugin> tag the applet loads with no problems using codebase="<%= request.getContextPath() %>/applets/facility", but that does not allow me to set my applet parameters dynamically. It works fine if I hardcode my parameters inside the <jsp:param> tag. However, I can explain this since it will require the JSP compiler to do multiple passes over the source code, and I don't think it does that.
My PC has the latest version of the JRE plugin 1.4.X.
Any help will be greatly appreciated.
Maizo