<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="com.test.SendTest"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<SCRIPT LANGUAGE="JavaScript">
  function send()
   {
      document.write("haha");
      document.write("<%SendTest st = new SendTest()%>");
      document.write("<st.str()>");
      document.write("haha");
   }
</script>
<body><input type="button" NAME="Button" VALUE="单击这里看看效果" onclick="send()"></body>
</html>

解决方案 »

  1.   

    ("<%SendTest st = new SendTest()%>");
    要加一个分号,表示语句结束
    ("<%SendTest st = new SendTest();%>");
      

  2.   

    你的java代码实在服务器端执行的
    而javascript是客户端执行的
    这样改试试:
    <%@ page contentType="text/html; charset=gb2312" %>
    <%@ page import="com.test.SendTest"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <SCRIPT LANGUAGE="JavaScript">
      function send(haha)
       {
          document.write(haha);
       }
    </script>
    <body><input type="button" 
           NAME="Button" 
           VALUE="单击这里看看效果" 
           onclick="send('<%=new SendTest().str()%>')"></body>
    </html>