how to import and display an applet from JSP
i m using netbeans 5.0
i have class named myapplet.class
and jsp named myjsp.jsp
now i want to access(import) this myapplet.class from jsp
also i want to display this applet from this jsp
i am able to do either thing but not both
so please help me it is so urgent and important for me bcoz
i have to complete my project as early as possible
Thanks in advance
# 1
Take a look at the jsp:plugin tag here: http://java.sun.com/products/jsp/syntax/2.0/syntaxref2023.html#1004158
# 2
my jsp source file page path is D:\Reliance project\WebApplication3\web\
and classes path is D:\Reliance project\WebApplication3\build\web\WEB-INF\classes\
-
so problem is that if i want to use myapplet.class then i have to put my class in D:\Reliance project\WebApplication3\build\web\WEB-INF\classes\ location
but at that time i am not able to display this applet on my jsp
--
if i put my myapplet.class in
D:\Reliance project\WebApplication3\web\ then i m able to display
applet but not able to access(import) this class
hope you will got the problem!!!
thanks for your reply !!!
# 3
Are you using a container like Tomcat?
As long as the application's /WEB-INF/ folder is visible to the container, it should work, make sure your application's docBase or appBase is properly set in Tomcat server.xml or <Context>.xml
It's better to develop independent of an IDE , first to understand the concepts.
# 4
> my jsp source file page path is D:\Reliance
> project\WebApplication3\web\
>
> and classes path is D:\Reliance
> project\WebApplication3\build\web\WEB-INF\classes\
> -
> so problem is that if i want to use myapplet.class
> then i have to put my class in D:\Reliance
> project\WebApplication3\build\web\WEB-INF\classes\
> location
>
> but at that time i am not able to display this applet
> on my jsp
>
>
> --
> if i put my myapplet.class in
> D:\Reliance project\WebApplication3\web\ then i m
> able to display
> applet but not able to access(import) this class
>
> hope you will got the problem!!!
>
> thanks for your reply !!!
try to set the path of your applet on jsp something like this
"WEB-INF/classes/myclass.class"
# 5
Put your applet class inside a package. A few days ago, I saw that there was a problem when the class was not placed in a package. I don't remember the thread, but it doesn't hurt to try.
# 6
Is there any alternative method to put my custom package else where instead of to put at \WebApplication3\build\web\WEB-INF\classes\
# 7
Apart from having to compile your application and package into a .war
for deployment into a Tomcat or alike, if you have an applet and a page
, it will sit (for simplicity here) inside the "application package-name"
folder e.g. it seams here to be "Webapplication3". An applet "is not"
a "web application reliant" component , you can call it from a normal
html page from a web server directory "BUT" if you have a jsp page
and server and you must use the "specialist jsp tag system"
below. The code base is the compiled and .war 'ed application
name that becomes the folder when loaded into the server by its deployer application( Webapplication3 ).
code= and codebase= are almost always present as attributes
in an html page also and the nested param tag almost always
too.
The URLmentioned previously was used to build the partial
example below this:
http://java.sun.com/products/jsp/syntax/2.0/syntaxref2023.html#1004158
the tag:jsp:plugin
attribute:type="applet"
attribute:code="myappletname.class"
attribute: codebase="Webapplication3"
start NESTED param declarations tag:
jsp:params
a parameter example tag:
jsp:param name="dynamiclist" value="item1,item2,item3,item4,item-e.t.c." /
end empty param tag
/jsp:paramsend tag nested params block
/jsp:pluginplugin block end tag
# 8
I have tried these all but still have same problem
# 9
Post the relevant code from the JSP and Applet and the directory structure of your Java Classes including Applet.
# 10
WebApplication3\web\myjsp.jsp
WebApplication3\web\WEB-INF\classes\p\p.myapplet.class
at this time i am able to import p.myapplet.class but not
able to display this applet in myjsp.jsp
please suggest me
<jsp:plugin type="applet" code="?" codebase="?"
width="1000" height="1000"
jreversion="1.2">
<jsp:fallback>Unable to start Java Plug-in for applet.</jsp:fallback>
</jsp:plugin>
# 11
Why do you have classes\p\p.myapplet.class ?
it should be classes\p\myapplet.class ,
post the relevant code of the applet. How have you declared the package for that applet?
<jsp:plugin type="applet" code="?" codebase="?"
width="1000" height="1000"
jreversion="1.2">
<jsp:fallback>Unable to start Java Plug-in for applet.</jsp:fallback>
</jsp:plugin>
Did you read this?
http://java.sun.com/products/jsp/syntax/2.0/syntaxref2023.html#1004158
code="myapplet.class" and codebase="/yourProjectDirectoryName"
# 12
in p directorymyapplet.java file --package p;.................... other code
# 13
is there any another option of web-inf/classes to put mycustom package ?
# 14
can any body help how to give code base for applet from jsp
# 15
> can any body help how to give code base for applet> from jspTake a look at my post on this thread: http://forum.java.sun.com/thread.jspa?forumID=45&threadID=5148764