登录检查页面:
<html>
<head>
<title>登录检查</title>
<%@ page session="true" %>
<%@ page contentType="text/html;charset=gb2312" %> </head><body bgcolor="#ccccff"><%@ page language="java"  %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page  import="java.sql.*" %>
<%
   String regName=(String)request.getParameter("username"); 
      regName=regName.trim();
   
   String regPassword=(String)request.getParameter("password");
      regPassword=regPassword.trim();   String regEmail=(String)request.getParameter("useremail");
      regEmail=regEmail.trim();   String regHomepage=(String)request.getParameter("homepage");
      regHomepage=regHomepage.trim();
 
%>
 <jsp:useBean id="reg" scope="page" class="test.chatreg" />显示这一句错误。
<%
  
  String sql="select * from chao where username='" + regName + "'";
  ResultSet rs = reg.executeQuery(sql); 
  if(rs.next()) { rs.close();
  
  out.println("<center><h2 >对 不 起, 你 的 大 名 已 经 存 在</h2> </center><br> <br>");
  out.println( "<center><a href=\"reg.jsp\"  > 重 新 注 册 </a></center><br> "); 
  out.println( "<center><a href=\"chao.jsp\"  > 我 不 注 册 了 </a></center> ");

else

 String strSQL="insert into chao(username , password , email ,homepage ) values('" + regName + "',  '" + regPassword +"'  ,  '" + regEmail + "'  , '" + regHomepage + "') ";
 reg.executeQuery(strSQL);
 out.println("<center><h2 color=red>恭 喜 你 注 册 成 功 !</h2> </center><br> <br>");
 out.println( "<center><a href=\"chao.jsp?regName\"  > 返回 </a></center> "); 

%> 
</body>
</html>
而test文件夹下的chatreg.java的代码如下。
package test;
import java.sql.*;public class  chatreg{
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:chao";
Connection conn = null;
ResultSet rs = null;public chatreg() {
try {
Class.forName(sDBDriver); 
}
catch(java.lang.ClassNotFoundException e) {
System.err.println("chao: " + e.getMessage());
}
}public ResultSet executeQuery(String sql) {
rs = null;
try {
conn = DriverManager.getConnection(sConnStr); 
Statement stmt = conn.createStatement();
rs = stmt.executeQuery(sql);

catch(SQLException ex) { 
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
}
}

解决方案 »

  1.   

    既然都用了<% %>了,那就写在<%%>里就行了,还用什么标签,这样看起来更乱了,还不如写在<%%>里呢
      

  2.   

    type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 16 in the jsp file: /web/conform.jspGenerated servlet error:
        [javac] Compiling 1 source fileC:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\web\conform_jsp.java:62: package test does not exist
          test.chatreg reg = null;
              ^An error occurred at line: 16 in the jsp file: /web/conform.jspGenerated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\web\conform_jsp.java:64: package test does not exist
            reg = (test.chatreg) _jspx_page_context.getAttribute("reg", PageContext.PAGE_SCOPE);
                       ^An error occurred at line: 16 in the jsp file: /web/conform.jspGenerated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\web\conform_jsp.java:66: package test does not exist
              reg = new test.chatreg();
                            ^An error occurred at line: 40 in the jsp file: /web/conform.jspGenerated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\web\conform_jsp.java:111: cannot find symbol
    symbol  : variable Name
    location: class org.apache.jsp.web.conform_jsp
       if((Name.length()<3)||(Name.length()>8))
           ^An error occurred at line: 40 in the jsp file: /web/conform.jspGenerated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\web\conform_jsp.java:111: cannot find symbol
    symbol  : variable Name
    location: class org.apache.jsp.web.conform_jsp
       if((Name.length()<3)||(Name.length()>8))
                              ^An error occurred at line: 54 in the jsp file: /web/conform.jspGenerated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\web\conform_jsp.java:129: cannot find symbol
    symbol  : variable Name
    location: class org.apache.jsp.web.conform_jsp
          for(int i=0;i<Name.length();i++)
                        ^An error occurred at line: 54 in the jsp file: /web/conform.jspGenerated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\web\conform_jsp.java:131: cannot find symbol
    symbol  : variable Name
    location: class org.apache.jsp.web.conform_jsp
               if( Name.charAt(i) == c.charValue() )
                   ^An error occurred at line: 67 in the jsp file: /web/conform.jspGenerated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\web\conform_jsp.java:166: cannot find symbol
    symbol  : variable Name
    location: class org.apache.jsp.web.conform_jsp
                else if( UserName.contains(Name))            
                                           ^An error occurred at line: 89 in the jsp file: /web/conform.jspGenerated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\web\conform_jsp.java:182: cannot find symbol
    symbol  : variable Name
    location: class org.apache.jsp.web.conform_jsp
        UserName.addElement(Name);
                                    ^An error occurred at line: 89 in the jsp file: /web/conform.jspGenerated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\web\conform_jsp.java:183: cannot find symbol
    symbol  : variable Name
    location: class org.apache.jsp.web.conform_jsp
                Name=new String(Name.getBytes("iso-8859-1"),"GBK");  
                ^An error occurred at line: 89 in the jsp file: /web/conform.jspGenerated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\web\conform_jsp.java:183: cannot find symbol
    symbol  : variable Name
    location: class org.apache.jsp.web.conform_jsp
                Name=new String(Name.getBytes("iso-8859-1"),"GBK");  
                                ^An error occurred at line: 89 in the jsp file: /web/conform.jspGenerated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\web\conform_jsp.java:184: cannot find symbol
    symbol  : variable Name
    location: class org.apache.jsp.web.conform_jsp
                session.putValue("Name", Name); 
                                         ^An error occurred at line: 89 in the jsp file: /web/conform.jspGenerated servlet error:
    Note: C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\web\conform_jsp.java uses or overrides a deprecated API.An error occurred at line: 89 in the jsp file: /web/conform.jspGenerated servlet error:
    Note: Recompile with -Xlint:deprecation for details.An error occurred at line: 89 in the jsp file: /web/conform.jspGenerated servlet error:
    Note: C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\web\conform_jsp.java uses unchecked or unsafe operations.An error occurred at line: 89 in the jsp file: /web/conform.jspGenerated servlet error:
    Note: Recompile with -Xlint:unchecked for details.
    12 errors
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
    org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:553)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
      

  3.   

    1#说的对:<jsp:useBean id="reg" scope="page" class="test.chatreg" />这已经是标签了。你怎么可以写在小脚本里面呢。小脚本是用来写java代码的。标签不能放里面。
        !!!!!!!!!当然会出错了。
      

  4.   

    package test does not exist !~~
      

  5.   

    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\web\conform_jsp.java:62: package test does not existpackage test does not exist 找不到test包
    看看你的web-inf/classes下有没有test包
      

  6.   

    An error occurred at line: 16 in the jsp file: /web/conform.jsp 
    这行有错误,没有找到test包
      

  7.   

    下面的错误也是因为没有test包的引起的。