不好意思,我也是刚开始学习,只知道通过bean调用参数,这个就不明白了,关注!顶!

解决方案 »

  1.   

    是这样的,我用的是tomcat4.1.12我知道在shtml文件中调用,我的test.shtml文件放在C:\tomcat\webapps\examples目录下,servlet类文件放在C:\tomcat\webapps\examples\WEB-INF\classes\project目录下,test.shtml的代码如下:
    <html>
    <head>
    <title>Java Servlet Sample - CompanyUser</title>
    </head>
    <body>
    <servlet 
    code=project.CompanyUser>
    <param name=Company1 value=hello>
    </servlet>
    </body>
    </html>
    结果无法调用,我想是我的code写错了,应该如何写才行?请高手指点!
      

  2.   

    study_body,大侠,你指什么?我是servlet,不是jsp啊
      

  3.   

    使用JAVASCRIPT自动提交HTML的表单,action指向你的servlet,然后再由你的servlet调用你的index.html同时也可以传递参数。
      

  4.   

    将index.html改成index.jsp不就是jsp了吗?
      

  5.   

    index.html
    -------------------------
    <span id="a"></span>
    <iframe src="/servlet/myServlet" hspace="0" vspace="0" width="0" height="0" scrolling="no" frameborder="0"></iframe>
    ---------------------------
    myServlet
    ------------------
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;public class myServlet extends HttpServlet {    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
        {
            response.setContentType("text/html;charset=gb2312");
    request.setCharacterEncoding("GB2312");
            PrintWriter out = response.getWriter();
    String s="";
    s+="<html>";
    s+="<head>";
    s+="<title>test</title>";
    s+="<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">";
    s+="</head>";
    s+="<body>";
    s+="<h1>test</h1>";
    s+="</body>";
    s+="</html>";
    out.println("<script>parent.a.innerHTML='"+s+"';</script>");
        }    public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
        {
    doGet(request,response);
        }
    }
    ---------------------
    编译,在浏览器输入http://localhost:8080/index.html
    我这里测试通过!
    ok???
      

  6.   

    beyond_xiruo大侠,如果是写成Server-Side Includes怎么写,就象我上面写的那种的?
      

  7.   

    beyond_xiruo大哥.我按你的方法运行了,还是不行src="/servlet/myServlet"是通过什么指定的啊?
      

  8.   

    在你放入tomcat 时,应修改你的web-inf 目录的web.xml.
    可C:\tomcat\webapps\examples\WEB-INF参考目录中web.xml.
      

  9.   

    我输入的地址是src="http://192.168.0.78:8080/examples/servlet/myServlet",最开始几次运行成功了,可后来有出错了,说网页有错误,详细信息是:没有权限,URL: http://192.168.0.78:8080/examples/servlet/myServlet