Roshan
Roshan

Reputation: 645

Applet Class Not Found Error

i have just started learning jsp, i came across running Applet from jsp, the code below doesn't seems to work.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>InfoVisual</title>
    </head>
    <body>
    <jsp:plugin type="applet"  codebase="WEB-INF/classes" code="DemoApplet.class"  width="400" height="400">
      <jsp:fallback>
       <p>Unable to load applet</p>
       </jsp:fallback>
    </jsp:plugin>
        <input name="btnShow" value="Show" type="submit">
    </body>
</html>

My eclipse project structure is like below

enter image description here

I don't know why i can't see the applet running. Have i placed files in right folders???

Upvotes: 0

Views: 2923

Answers (2)

Roshan
Roshan

Reputation: 645

this code worked perfectly:

<applet code="DemoApplet.class" name="DemoApplet" archive="DemoApplet.jar" width=300 height=300>
</applet>

and here is my project structure:

enter image description here

Thanx for the help :))

Upvotes: 0

Reimeus
Reimeus

Reputation: 159754

Classes in WEB-INF/classes are only visible to server-side code such as servlets. Instead create a JAR file containing the compiled classes required to run the applet are place them in the same location as the JSP file. The plugin tag will then look like

<jsp:plugin type="applet"  code="DemoApplet.class" archive="MyAppletJar.jar" width="400" height="400">
  <jsp:fallback>
   <p>Unable to load applet</p>
   </jsp:fallback>
</jsp:plugin>

Upvotes: 2

Related Questions