看了网上很多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";
}
}急啊

解决方案 »

  1.   

    你把源文件(.java)放在webContent/applet目录下怎么能行呢??至少也应该是class文件吧,还有你那些archive所引用的包,又都不在webContent目录下问题太多了document.WindowAuth.what();这样用也有问题
      

  2.   

    我把jar包放在WEB-INF/lib目录下面了能指点一下吗? 该怎么做
      

  3.   


    lib下面没有的,这个目录是http不能访问的
      

  4.   

    所有archive引用的包放在与jsp相同的目录(当然也可以不相同,修改一下jsp中archive引用的路径)。假如你要运行的applet对应的class是applet.WindowAuth.class那么目录结构是这样的/WebContent
         |-------New.jsp
         |-------***.jar
         |-------applet
                   |------WindowAuth.classjs中也不能直接用 document.WindowAuth.what();
    应该用document.getElementById("WA").what();
      

  5.   

    不行啊,
    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>