wood burning stoves 2.0*
The moose likes Applets and the fly likes Class not found exception while running an applet in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Class not found exception while running an applet in jsp" Watch "Class not found exception while running an applet in jsp" New topic
Author

Class not found exception while running an applet in jsp

Aadil Ahmed
Greenhorn

Joined: Dec 20, 2012
Posts: 3

Hi Guys, I would deeply appreciate any help from you.
In short, my applet does not load when i call it from jsp page.
I am using eclipse juno,Apache tomcat 7.x as the environment to develop the program.

the following is my jsp page. (examApplet.jsp)

<%@ 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><title>Exam Applet</title></head>
<body background="paper_bg.gif">
<center><h2>Online Exam</h2></center>
<center>

<jsp:plugin type="applet" code="examapplet.class" codebase="WEB-INF/classes" width="500" height="280">
<jsp:fallback>
<p> Unable to load applet </p>
</jsp:fallback>
</jsp:plugin>

</center>
</body>
</html>


I know i am messing up in the codebase part of the plug in.
the error is the same if i run the application on eclipse or export it to a war file and deploy it in apache.

i have tried both the <applet> tag and the <jsp:Plugin> tag, the applet tag displays nothing on the page where as the jsp:Plugin tag shows an empty box which loads the java run-time plugin on the browser and pops up a message saying class not found error.

my file system on eclipse is:
project>
.settings
build>
classes(all .class files are in this folder)
servlets>
(contains all my .java files)
webcontent>
(contains all the.jsp files)
META-INF
WEB-INF>
web.xml

the file system on creating a .war file is:
project>
(contains all .jsp files and images needed)
META-INF
WEB-INF>
classes(Contains all class files)
lib
web.xml

it is only the plugin function that doesnot work, the applet runs on its own if run as a java applet on eclipse.
I am not a pro at programming, i have really hit a roadblock. any help as soon as possible would be really appreciated.
attaching the screenshot of the webpage on the eclipse browser


[Thumbnail for Capture.JPG]

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8



Here you tell the browser to download the applet from the WEB-INF/classes folder (relative to the URL of the page which this code is in). Entries in that folder cannot be accessed by the browser, so your applet can't be downloaded.

You should put your applet, generally speaking, in the same set of folders in which your HTML and Javascript and CSS files are.
Aadil Ahmed
Greenhorn

Joined: Dec 20, 2012
Posts: 3

Hi Paul, I tried using the WEB-INF/classes in the codebase it didnt work, i have the same error.
even tried placing the examapplet.class in the same folder as my jsp, that didnt work either.
any other suggestions?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

I would suggest going back several steps. Start by writing an HTML page which includes an applet. No web application stuff at all, just those two things. Get that working first.
Aadil Ahmed
Greenhorn

Joined: Dec 20, 2012
Posts: 3

It is resolved now, It was as simple as having the class files outside the WEB-INF folder.
The explanation is that the client's browser cannot access files inside the WEB-INF.

just remember to set codebase="."

Thank you Paul
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class not found exception while running an applet in jsp