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

[415 byte] By [Anand_Agrawala] at [2007-11-26 21:19:21]
# 1
Take a look at the jsp:plugin tag here: http://java.sun.com/products/jsp/syntax/2.0/syntaxref2023.html#1004158
appy77a at 2007-7-10 2:58:11 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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 !!!

Anand_Agrawala at 2007-7-10 2:58:11 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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.

appy77a at 2007-7-10 2:58:11 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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"

jgalacambraa at 2007-7-10 2:58:11 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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.
appy77a at 2007-7-10 2:58:11 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Is there any alternative method to put my custom package else where instead of to put at \WebApplication3\build\web\WEB-INF\classes\
Anand_Agrawala at 2007-7-10 2:58:11 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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

nicephotoga at 2007-7-10 2:58:11 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
I have tried these all but still have same problem
Anand_Agrawala at 2007-7-10 2:58:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
Post the relevant code from the JSP and Applet and the directory structure of your Java Classes including Applet.
appy77a at 2007-7-10 2:58:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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>

Anand_Agrawala at 2007-7-10 2:58:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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"

appy77a at 2007-7-10 2:58:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 12
in p directorymyapplet.java file --package p;.................... other code
Anand_Agrawala at 2007-7-10 2:58:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 13
is there any another option of web-inf/classes to put mycustom package ?
Anand_Agrawala at 2007-7-10 2:58:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 14
can any body help how to give code base for applet from jsp
vel_javaa at 2007-7-10 2:58:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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
appy77a at 2007-7-21 18:15:35 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...