javascript调用applet问题,急

ahutbxh 2012-11-13 11:26:50
看了网上很多javascript调用applet的例子,然是为什么我总是实验不成功,我的目录是这样的


我的为题是
1.我该把java程序放在哪里? class文件放在哪里?
2.javscript中是这样的额
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript" language="javascript" charset="gb2312">
function Http()
{
//document.WindowAuth.login("1","2");
//var app=new WindowAuth();
//app.login("tomcat","tomcat");
document.WindowAuth.what();
alert("111");
}
</script>
</head>

<body onload="accessApplet()">
<applet id="WA" name="WindowAuth" code="WindowAuth.class" codebase="WEB-INF/lib" archive="WindowAuth.jar,commons-codec-1.6.jar,commons-logging-1.1.1.jar,fluent-hc-4.2.2.jar,httpclient-4.2.2.jar,httpclient-cache-4.2.2.jar,httpcore-4.2.2.jar,httpmime-4.2.2.jar" width="0" height="0" >
</applet>
.........
</body>
应该是没错的,但是调用applet方法始终不成功
java文件时
public class WindowAuth extends Applet{
......
public String what(){
JOptionPane.showMessage(null,"111");
return "122";
}
}

急啊
...全文
132 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ahutbxh 2012-11-13
  • 打赏
  • 举报
回复
引用 1 楼 trocp 的回复:
你把源文件(.java)放在webContent/applet目录下怎么能行呢?? 至少也应该是class文件吧,还有你那些archive所引用的包,又都不在webContent目录下 问题太多了 document.WindowAuth.what();这样用也有问题
我把jar包放在WEB-INF/lib目录下面了 能指点一下吗? 该怎么做
oO临时工Oo 2012-11-13
  • 打赏
  • 举报
回复
你把源文件(.java)放在webContent/applet目录下怎么能行呢?? 至少也应该是class文件吧,还有你那些archive所引用的包,又都不在webContent目录下 问题太多了 document.WindowAuth.what();这样用也有问题
ahutbxh 2012-11-13
  • 打赏
  • 举报
回复
引用 5 楼 ahutbxh 的回复:
引用 4 楼 trocp 的回复:所有archive引用的包放在与jsp相同的目录(当然也可以不相同,修改一下jsp中archive引用的路径)。假如你要运行的applet对应的class是applet.WindowAuth.class那么目录结构是这样的 /WebContent |-------New.jsp |-------***.jar……
ok了,谢谢,结贴了。
ahutbxh 2012-11-13
  • 打赏
  • 举报
回复
引用 4 楼 trocp 的回复:
所有archive引用的包放在与jsp相同的目录(当然也可以不相同,修改一下jsp中archive引用的路径)。假如你要运行的applet对应的class是applet.WindowAuth.class那么目录结构是这样的

/WebContent
|-------New.jsp
|-------***.jar
|-------ap……

不行啊,
jsp文件中是这样的
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript" language="javascript" charset="gb2312">
function Http()
{
//document.WindowAuth.login("1","2");
//var app=new WindowAuth();
//app.login("tomcat","tomcat");
document.getElementById("WA").what();
//alert("111");
}
</script>
</head>

<body onload="accessApplet()">
<applet id="WA" name="WindowAuth" code="WindowAuth.class" codebase="./applet" archive="commons-codec-1.6.jar,commons-logging-1.1.1.jar,fluent-hc-4.2.2.jar,httpclient-4.2.2.jar,httpclient-cache-4.2.2.jar,httpcore-4.2.2.jar,httpmime-4.2.2.jar" width="0" height="0" >
</applet>
</body>
oO临时工Oo 2012-11-13
  • 打赏
  • 举报
回复
所有archive引用的包放在与jsp相同的目录(当然也可以不相同,修改一下jsp中archive引用的路径)。假如你要运行的applet对应的class是applet.WindowAuth.class那么目录结构是这样的 /WebContent |-------New.jsp |-------***.jar |-------applet |------WindowAuth.class js中也不能直接用 document.WindowAuth.what(); 应该用document.getElementById("WA").what();
oO临时工Oo 2012-11-13
  • 打赏
  • 举报
回复
引用 2 楼 ahutbxh 的回复:
引用 1 楼 trocp 的回复:你把源文件(.java)放在webContent/applet目录下怎么能行呢?? 至少也应该是class文件吧,还有你那些archive所引用的包,又都不在webContent目录下 问题太多了 document.WindowAuth.what();这样用也有问题 我把jar包放在WEB-INF/lib目录下面了 ……
lib下面没有的,这个目录是http不能访问的

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧