I have developed a JSP webapplication with an Applet. I am not able to display the applet from my JSP page.
Below is the code:
<applet codebase="http://localhost:8080/av_applet_jsp/applets" code="av_app.class" WIDTH="200" HEIGHT="100">
av_app.class
is located inside Webcontent/applets/
Where I am going wrong?
Here is my applet class:
public class av_app extends Applet {
@Override
public void paint(Graphics g) {
int inset;
int rectWidth, rectHeight;
g.setColor(Color.pink);
g.fillRect(0,0,300,160);
g.setColor(Color.green);
inset = 0;
rectWidth = 299;
rectHeight = 159;
while (rectWidth >= 0 && rectHeight >= 0) {
g.drawRect(inset, inset, rectWidth, rectHeight);
inset += 15;
开发者_Python百科 rectWidth -= 30;
rectHeight -= 30;
}
}
}
I am able to see applet using applet viewer. What I am doing wrong in my JSP page?
When I tried an example code it's working:
<applet codebase="http://java.sun.com/applets/NervousText/1.1"
code="NervousText.class" width=400 height=75>
<param name="text" value="Welcome to HotJava!">
</applet>
With a codebase of..
http://localhost:8080/av_applet_jsp/applets
..and code attribute of..
av_app.class
..the JVM will be looking for the class in..
http://localhost:8080/av_applet_jsp/applets/av_app.class
OTOH you state the applet is actually located at..
http://localhost:8080/Webcontent/applets//av_app.class
Either move the class to where the applet is expecting to find it, or change the HTML to look where it is located.
problem was i also mentioned package name in the class ,after removing its working fine ,thnkx for the answers guys
common help
"http://download.oracle.com/javase/tutorial/deployment/applet/problemsindex.html"
What happens when you browse to http://localhost:8080/av_applet_jsp/applets
? Is your class file there?
On another note, it appears that you did not package your applet as a JAR. Why not?
精彩评论