如题....
我的CGI程序代码:
#include<stdio.h>
#include<string.h>
int main(void)
{
printf("Contenttype:text/html;charset=iso-8859-1\n\n");
printf("<html>\n");
printf("<head><title>JAVA HelloWorld CGI</title></head>\n");
printf("<body>\n");
printf("<applet code=HelloWorld.class width=200 height=200>\n");
printf("</applet>\n");
printf("</body>\n");
printf("</html>\n");
fflush(stdout);
}
编译完用浏览器访问时,总是一个红色的叉(ㄒoㄒ)...然后浏览器都关不了了...报的错误是:
Java Plug-in 1.5.0_06
使用 JRE 版本 1.5.0_06 Java HotSpot(TM) Client VM
用户主目录 = C:\Documents and Settings\Administrator
----------------------------------------------------
c: 清除控制台窗口
f: 终结在结束队列上的对象
g: 垃圾收集
h: 显示此帮助消息
l: 转储类载入程序列表
m: 打印内存使用
o: 触发日志记录
p: 重新载入代理配置
q: 隐藏控制台
r: 重新载入策略配置
s: 转储系统和部署属性
t: 转储线程列表
v: 转储线程堆栈
x: 清除类载入程序高速缓存
0-5: 设置跟踪级别为<n>
----------------------------------------------------
载入:找不到类 HelloWorld.class。
java.lang.ClassNotFoundException: HelloWorld.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed.
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 10 more
Exception in thread "Thread-4" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "thread applet-HelloWorld.class" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
但是如果把
“ printf("<applet code=HelloWorld.class width=200 height=200>\n");
printf("</applet>\n");”
写在index.html中,是可以正常显示Helloworld的。。。(⊙_⊙)?
纠结了~各位前辈有没有什么高见???(ㄒoㄒ)
------解决方案--------------------
不是啊楼主,
我刚刚用ie,firefox,chrome,还有很多很多浏览器都试了一下,都没问题的
int main(string[] args){
cout << "<applet code='ww.class' width=200 height=200></applet>";
}
我就是这么简单啊,没甚么秘技