calling applet from a jsp; classNotFoundException
Hi All!
I am using servlet, struts and EJB to retrieve data from a database. JBoss provides the EJB container.
After a request is sent, a jsp is returned and I want to put some code inside the jsp to call an applet,
along with some other parameters for the applet.
The applet classes are in com/tienshan/applet/nbsa11 folder. This whole thing is in src folder.
I wrote the following code inside the jsp.
<applet code="com.tienshan.applet.nbsa11.NBSA110Main.class" archive="A11Test.jar" width=1000 height=900>
When I start the JBoss server and send a request, I can see that the jsp in which the above code is written
is called but immediately after that, I get the following error.
java.lang.ClassNotFoundException: com.tienshan.applet.nbsa11.NBSA110Main.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
etc.
When I check the contents of the A11Test.jar, I have com/tienshan/applet/nbsa11 folders and inside the nbsa11 folder, the NBSA110Main class.
A11Test jar is in the same folder as the jsp which calls NBSA110Main applet.
I tried with a war file (test.war) from JBoss's deploy folder and put this one instead of the A11test.jar,
with archive="test.war".
No change, even though the test.war also has the same folder structure: com/tienshan...
What am I missing? I copied the NBSA110Main class. directly in the same folder and (without the archieve parameter), tried to call the applet. Still no change.
Could someone please give me some hint?
Thank you.
tienshan
Re: calling applet from a jsp; classNotFoundException
The applet tag is reading com.tienshan.applet.nbsa11.NBSA110Main.class as if 'class' was the applet that you want to execute and 'NBSA110Main' as part of the package. So you can drop the '.class'. Another tip, there's a <jsp:plugin> tag that you might want to use.
http://java.sun.com/products/jsp/tag...xref.fm12.html
It will write the detection code for the Java Plugin. Something like the following:
<COMMENT>
<EMBED type="application/x-java-applet;version=1.4"
archive="my archive"
width="300"
height="300"
pluginspage="http://java.sun.com/products/plugin/index.html#download"
java_code="The package and applet"
java_codebase="My Code Base"
<NOEMBED>
</COMMENT>
</NOEMBED>
</EMBED>
Re: calling applet from a jsp; classNotFoundException
erm... the ".class" is REQUIRED in an applet, whether youre using applet, object or embed tags..
you can get a comprehensive html fragment for running an applet, in my signature link "JAR Tutorial" :)
populate the red sections with what you want..
lastly, you need to ensure that your jar file is being downloaded.. jar files, and applets are nOTHIGN to do with a JSP.. a jsp merely produces HTML, the browser reads the html and when it encounters an applet tag it fires off an http request for that applet files. in your case, you probably havent put the jar where you said you have (so the browser encounters http 404 when trying to download your jar)
Re: calling applet from a jsp; classNotFoundException
cjard,
I do have my jar file in the same directory as that of the jsp. No doubt about that. What I have yet to know is if the jar is being downloaded. How do I know this? Also, why do you say 404 error while I said I got classNotFoundException. The applet footer says : applet not initiated, no http error. I have to admit that I have not yet read your jar tutorial. Give me a day or two.
Goodz13,
Next time I will try with <jsp:plugin> tag. but for the nested path, I still have a lot to read and understand.
Thank you both of you.
Re: calling applet from a jsp; classNotFoundException
Did I type something stupid between <jsp and plugin>? An icon "Stick out tongue", is here, which is inadvertent. So many things to learn.
Re: calling applet from a jsp; classNotFoundException
Quote:
Originally Posted by Tienshan
cjard,
I do have my jar file in the same directory as that of the jsp. No doubt about that. What I have yet to know is if the jar is being downloaded. How do I know this? Also, why do you say 404 error while I said I got classNotFoundException. The applet footer says : applet not initiated, no http error. I have to admit that I have not yet read your jar tutorial. Give me a day or two.
it isnt necessarily the case that the applet must be in the same directory as the jsp.. it is simply that the JSP is generating some HTML to the browser, and that HTML says "hey browser, go load the applet from SOME PLACE" and when the browser goes and looks in SOME PLACE, it doesnt find the applet.
or maybe it found the appelt jar, but you didnt specify the name correctly.
i said "404" because that is the standard http response code for not finding a file. if you say to the browser, to load http://www.myhost.com/applets/myApplet.jar but it is not in that location, then the browser will experience a http 404 error when it tries to retrieve it
basically, now, to test your things, i wish for you to load your jsp page up in a browser, then do VIEW SOURCE and look where it is trying to load the applet from. the details there will not be correct, but i cant say for sure which detail is not correct because i dont know your filesystem structure.. it is either the url to the jar, or the name you have specified for the class to load inside the jar, or the url of the class if you arent using a jar
Quote:
Next time I will try with <jsp:plugin> tag. but for the nested path, I still have a lot to read and understand.
jsp : plugin contains a colon : followed by a P. together this combination of letters put s tongue-out smiley on the board. i've complained to brad before, but no change. if you want this silly thing to go away, tick the "disable smilies in this post" box. there is no way to ahve this option as ON by default
Re: calling applet from a jsp; classNotFoundException
Quote:
Originally Posted by cjard
"hey browser, go load the applet from SOME PLACE"
That "some place" was missing! :blush: I fixed the problem by adding codeBase entry in my <APPLET> tag. Thank you for the tip.
Re: calling applet from a jsp; classNotFoundException
no problem. note that applet tag is deprecated in favour of OBJECT 9ms) or EMBED (netscape)
ahh.. standards..