这是源码:<%@page contentType="text/html;charset=gb2312"%>
<%@page import="java.sql.*"%>
<%@ page import="com.mysql.jdbc.Driver" %>
<%

String      type    = null;
String       myuserid    = null;
String      myuserpass = null;
String      mySQL      = null;
String       companyID    = null; 
String       password    =null;
int         count      = 0;
Connection  conn=null;
Statement  stmt=null;
ResultSet rs=null;
//if(request.getParameter("userid")!=null){
   // session.setAttribute("s1",request.getParameter("userid"));
   // }
//cookie c=new cookie("name1",request.getParameter("userid"));
    //response.addCookie(c);
request.setCharacterEncoding("utf8");
type = request.getParameter("select1");


if(type.equals("选择登陆类型"))
 {
  response.sendRedirect("denglushibai1.htm");
     }
    if(type.equals("单位/企业"))
      {
     try{
         Class.forName("com.mysql.jdbc.Driver");
         }
         catch(ClassNotFoundException ce){
        out.println(ce.getMessage());
         }

         myuserid=request.getParameter("companyID");
         myuserpass=request.getParameter("password");
 
         
 
         if(myuserid==null)
     myuserid="";

         mySQL = "SELECT * FROM c_regist where companyID ='"+companyID+"'";
         mySQL = mySQL + "and password ='"+password+"'";

         try{
     Class.forName("com.mysql.jdbc.Driver");
       conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/job","root","123");
       stmt=conn.createStatement();
      rs=stmt.executeQuery(mySQL);
         while(rs.next()) 
        {  
       count++;
         }
        if(count>0) 
        {
   session.setAttribute("name1",companyID);
       response.sendRedirect("qiyeguanli.jsp"); 
         }
        else response.sendRedirect("denglushibai2.htm");
          }
          catch(SQLException e){
         System.out.println(e.getMessage());
          }
          finally{
       stmt.close();
       conn.close();
          }
      }
  if(type.equals("学生/个人"))
      {
     try{
        Class.forName("com.mysql.jdbc.Driver");
            }
         catch(ClassNotFoundException ce){
        out.println(ce.getMessage());
         }

         myuserid=request.getParameter("companyID");
         myuserpass=request.getParameter("password");
 
         
 
         if(myuserid==null)
     myuserid="";

         mySQL = "SELECT * FROM student where c_name ='"+myuserid+"'";
         mySQL = mySQL + "and password ='"+myuserpass+"'";

         try{
            conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/job","root","123");
            stmt=conn.createStatement();
            rs=stmt.executeQuery(mySQL);
         while(rs.next()) 
        {  
       count++;
         }
        if(count>0) 
        {
   session.setAttribute("name3",myuserid);
       response.sendRedirect("student.jsp"); 
         }
        else response.sendRedirect("denglushibai2.htm");
          }
          catch(SQLException e){
         System.out.println(e.getMessage());
          }
          finally{
       stmt.close();
       conn.close();
          }
      }
%> 

解决方案 »

  1.   

    下面是错误:请各位大侠指点一二
    type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Exception in JSP: /biyesheji/denglu.jsp:41: <%@page contentType="text/html;charset=gb2312"%>
    2: <%@page import="java.sql.*"%>
    3: <%@ page import="com.mysql.jdbc.Driver" %>
    4: <%
    5: 
    6:  String      type    = null;
    7:  String       myuserid    = null;
    Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause java.lang.NullPointerException
    org.apache.jsp.biyesheji.denglu_jsp._jspService(denglu_jsp.java:68)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)