GeeCON Prague 2014*
The moose likes Applets and the fly likes What Am I doing wrong with my codebase? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Applets
Bookmark "What Am I doing wrong with my codebase?" Watch "What Am I doing wrong with my codebase?" New topic
Author

What Am I doing wrong with my codebase?

Shamim Emon
Greenhorn

Joined: Jun 16, 2013
Posts: 8
Hi, I want to invoke an Applet from a jsp file.here is the jsp plugin I have used :

<jsp:plugin type="applet"
code="pk1/MyApplet.class" codebase="/AppletTest/src/pk1"
width="1400" height="800">
</jsp:plugin>

where AppletTest is my Dynamic web project.The jsp file is kept in WebContent folder and and MyApplet.java is stored in pk1 package.so could you please tell me whats wrong with my codbase??
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42061
    
  64
For starters, the code attribute takes a class name, not a file name. Class names contain dots, whereas file names contains slashes.

The codebase attribute should contain the root of the class directory hierarchy - that means it should not contain the package name. Also, does the "src" directory really contain class files? That sounds counter-intuitive.


Ping & DNS - my free Android networking tools app
Shamim Emon
Greenhorn

Joined: Jun 16, 2013
Posts: 8
Thanks for the reply.I was wrong about "src" directory.I am still unable to get the applet.If I understand you clearly then the code attribute should contain only class name even if it is in a pakage?like code="MyApplet.class"
also if the correct directory is "AppletTest\build\classes\pk1"where pk1 is the package name then codebase="/AppletTest/build/classes/" right? Still cant find the applet.So far I am only able to get the applet only when I make a jar file which is in the same directory as the jsp file by archile="somename.jar". Its kind of eating me why can't I do it with the code base .Some more help would be really appreciated.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42061
    
  64
What is the layout of your files and directories? What is the error you get in the Java Console?
Shamim Emon
Greenhorn

Joined: Jun 16, 2013
Posts: 8
Well, I get class not found exception.And,here is the layout of my flies:
AppletTest(Web dynamic project).There I have the package"pk1"which contrains the appletcode"MyApplet.Java"
"WebContent" folder contains the jsp file which contains the the code fragment I paste above.
Thanks once again
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42061
    
  64
Where the source file is is irrelevant - it's not used at runtime. Important is where the class file(s) is.

What HTML does get created by that JSP tag? Also, post the entire stack trace.

To make things easy you may wish to start out simple - don't use codebase, and instead keep the files in the same directory - meaning, the "pk1" directory should be in the same place as the JSP file.

Also, are you accessing the JSP directly? It gets more complicated if you hide it behind a servlet, because then the URL has no resemblance to the directory structure.

Lastly, try relative paths in the JSP tag. I'm not sure if absolute paths are supposed to work.
 
GeeCON Prague 2014
 
subject: What Am I doing wrong with my codebase?