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

applet is not running in jsp

Sanjay Chougule
Ranch Hand

Joined: Mar 04, 2008
Posts: 30
I want to run a applet in jsp.Currently it is giving Class not found Exception Error.please tell the possible solutions.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Where is the class file? It needs to be in a publicly accessible directory (not WEB-INF or one of its subdirectories); if it is, describe the directory structure you're using, and what the applet tag looks like.


Ping & DNS - updated with new look and Ping home screen widget
Sanjay Chougule
Ranch Hand

Joined: Mar 04, 2008
Posts: 30
hi !!!
i have kept .class file in different location , i hv used in public also i.e. out of web-inf folder ... in all cases i got same error ..
Sanjay Chougule
Ranch Hand

Joined: Mar 04, 2008
Posts: 30
& also i forgot to mention .. i m using eclipse for developing my application ,eclipse handle all the class files & place in a specific directory i.e. corresponding package hierarchy , so it is very hard to copy every time corresponding class file in public place manually .... isn't it..?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
If you want to deploy an applet, then you need an HTML page that contains an applet tag that properly references the applet classes and jar files (if any).

I don't know if Eclipse can help you generate that HTML file; if not, you may want to familiarize yourself with how it works, which you can at http://java.sun.com/docs/books/tutorial/deployment/applet/html.html

If you aren't planning on deploying the applet in a web page you may be better off making this a desktop application instead of an applet.
Sanjay Chougule
Ranch Hand

Joined: Mar 04, 2008
Posts: 30
i am also new in Eclipse...!!!
i am able to run a simple apllet in jsp page using <plugin> tag ... in this case HTML play no any role ... same way i want to run my applet in jsp, the only new thing in my applet is that i am using "JFreeChart".
( hope "classNotFond" Exception is not any related with "JFreeChart"...?? )

so i just want to confirm ,is this problem related to browser ? because while searching on google i got various results showing browser setting to fix this problem .
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Of course HTML plays a role - the JSP creates HTML.

Browser settings have nothing to do with this. It all depends on the <jsp:plugin> tag.

Whether the problem relates to your use of JFreeChart, we don't know - you haven't told us which class is missing (that's part of the exception stack trace). How are you referencing the JFreeChart jar file in the plugin tag? Where are the jar files located (to use JFreeChart you also need the JCommon jar file)?
Sanjay Chougule
Ranch Hand

Joined: Mar 04, 2008
Posts: 30
i am using plugin tag as.....
<jsp lugin type="applet" code="APNChart1.class" codebase="." jreversion="1.5" width="400" height="300">
</jsp lugin>

& i am using JfreeChart in APNChart1 Applet.
so do i need any .jar file to include in that plugin tag..?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Yes, you need the JFreeChart and JCommon jar files. The JSP specification should tell you how they can be incorporated into the <jsp:plugin> tag. Personally, I'd rather use an applet tag instead.

By the way, you can use the "Disable smilies in this post" checkbox if you want to post messages that contain colons (like in "jsp:plugin").
[ April 14, 2008: Message edited by: Ulf Dittmer ]
Sanjay Chougule
Ranch Hand

Joined: Mar 04, 2008
Posts: 30
by mistake i forget to disable smiles .
i have added all required .jar files ,
<html>
<body>
<APPLET CODE="APNChart1.class" codebase="/applets" archive="WEB-INF/lib/jcommon-1.0.12.jar, WEB-INF/lib/jfreechart-1.0.9.jar" WIDTH=400 HEIGHT=300>
<p>Chart Applet</p>
</APPLET>
</html>

now i don't get any error , only "Chart Applet" string get display ,applet is not there .
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
As I said before, you can't put classes or jar file that you want to use with applets into WEB-INF - nothing in that directory will be served. You need to put them into a publicly accessible directory. The easiest would be to put them in the same directory as the JSP.
Sanjay Chougule
Ranch Hand

Joined: Mar 04, 2008
Posts: 30
i am using eclipse for my application hence i can't put all the files together .
After build project in Eclipse project directory structure is ...

for APNChart1.class file path is ..
webapps->Root->web-inf->classes->com->applet

for jsp file path is
webapps->Root->web-inf->jsp

so i am not able to create separate folder which contain jsp & all required files together .
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Eclipse is a development environment, not a runtime environment. Where it wants to keep files isn't necessarily indicative of where they need to end up on a server.

You will need to move all those files outside of WEB-INF (and I assume you actually mean "WEB-INF", not "web-inf"): the JSP page, the applet classes and the jar files.
JayKumar Chimata
Greenhorn

Joined: Jul 09, 2007
Posts: 3
Maintain the applet in the jsp folder,

If you are embedding the applet in the html file, you need to keep the class file of applet and the html file in the same folder.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: applet is not running in jsp
 
Similar Threads
Applet with a ServerSocket
Clock
WA #1.....word association
Java program protection.
Clock