无法从Struts Web应用程序运行Applet

时间:2014-09-22 20:03:19

标签: java jsp web-applications applet struts

我已经按照相关的教程,但我仍然被卡住了。我想将一个applet嵌入到由struts 1.x驱动的jsp中。我用一个小程序HelloWorld.jar打包了一个jar HelloWorld.class。它托管在本地网络服务器localhost:7001/WebContent/上。应用程序的其他部分工作,并且jsp在没有applet的情况下加载就好了。但是,当applet回发到服务器以检索jar和类位置时,我会收到FileNotFoundExceptionClassNotFoundException。奇怪的是,它回到了我没想到的路径:

network: Connecting http://localhost:7001/WebContent/HelloWorld.jar with proxy=DIRECT
network: Connecting http://localhost:7001/WebContent/HelloWorld.jar with cookie     "JSESSIONID=wS7LJg3p3fFfJL4RTcz7ylmpF68jllMgrd2JtYh7ZyywLqKCQy5p!2106205894"
java.io.FileNotFoundException: http://localhost:7001/WebContent/HelloWorld.jar
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at sun.plugin.PluginURLJarFileCallBack.downloadJAR(Unknown Source)
    at sun.plugin.PluginURLJarFileCallBack.access$000(Unknown Source)

network: Cache entry not found [url: http://localhost:7001/WebContent/HelloWorld.class, version:         null]
network: Connecting http://localhost:7001/WebContent/HelloWorld.class with proxy=DIRECT
network: Connecting http://localhost:7001/WebContent/HelloWorld.class with cookie     "JSESSIONID=wS7LJg3p3fFfJL4RTcz7ylmpF68jllMgrd2JtYh7ZyywLqKCQy5p!2106205894"
network: Cache entry not found [url: http://localhost:7001/WebContent/HelloWorld/class.class,     version: null]
network: Connecting http://localhost:7001/WebContent/HelloWorld/class.class with proxy=DIRECT
network: Connecting http://localhost:7001/WebContent/HelloWorld/class.class with cookie     "JSESSIONID=wS7LJg3p3fFfJL4RTcz7ylmpF68jllMgrd2JtYh7ZyywLqKCQy5p!2106205894"
java.lang.ClassNotFoundException: HelloWorld.class
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)

无论我将代码,代码库或归档参数更改为什么,我都会向具有相同故障的相同路径获取相同的请求。相关代码如下:

JSP(请注意,我已尝试code="HelloWorld.class"):

<div> <jsp:plugin type="applet" codebase="." code="HelloWorld" archive="HelloWorld.jar" width="600" height="480" />
</div>

申请结构:

/
/src/
/WebContent/pages/myJsp.jsp
/WebContent/pages/HelloWorld.jar
/WebContent/WEB-INF/
...

HelloWorld.java

import java.applet.Applet;
import java.awt.Graphics;

public class HelloWorld extends Applet {

    public void init() {
        resize(150,25);
    }

    public void paint(Graphics g) {
        g.drawString("Hello world!", 50, 25);
    }

}

非常感谢任何帮助。

0 个答案:

没有答案