check代码:<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" %>
<% request.setCharacterEncoding("gb2312"); %>
<%@ page import="com.bwm.page.Show"%>
<%@ page import="com.bwm.db.Condb"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head><body>
<%
   Condb con=new Condb();
   //Connection conn=con.getConnection();
   Show show=new Show();
   String name=request.getParameter("name");
   String password=request.getParameter("password");
   String sql="select * from tb_Person where Username='"+name+"' and Password='"+password+"'";
   ResultSet rs=con.executeQuery(sql);
   if(rs.next()){
   String strsql=rs.getString(1);
       session.setAttribute("name",name);
       session.setAttribute("password",password);
       session.setAttribute("groupid",strsql);
       response.sendRedirect("index.htm");
   }else{
       out.print(show.errorBox("你输入的用户名或密码有误","错误信息"));
       out.close();
}    
//if(conn!=null){
//    conn.close();
//}
con.close();
%></body>
</html>

解决方案 »

  1.   

    说是空指针错误,type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
      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)
    root cause java.lang.NullPointerException
      org.apache.jsp.user.check_jsp._jspService(check_jsp.java:67)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
      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)
    note The full stack trace of the root cause is available in the Tomcat logs
      

  2.   

    我也是新手
    把url 改成这样试试url="jdbc:microsoft:sqlserver://servername:1433;DatabaseName=db_Scenince";
    user="sa";
    password="123";DriverManager.getConnection(url, user, password);
      

  3.   

    ResultSet rs=con.executeQuery(sql);
       if(rs.next()){
    改成:
    try{
     ResultSet rs=con.executeQuery(sql);
       if(!rs.next()){...}
    }
    catch (SQLException ex) {
          ex.printStackTrace();
        }
      

  4.   

    String url="jdbc:microsoft:sqlserver://servername:1433;DatabaseName=db_Scenince;user=sa;password=123";
    改成:
    url="jdbc:microsoft:sqlserver://"+servername+":1433:databasename=db_Scenince";
    username="sa";
    password="123";
    Connection conn=DriverManager.getConnection(url,username,password);
    其他没发现问题
      

  5.   

    再说一句,最好用PreparedStatement
      

  6.   

    String url="jdbc:microsoft:sqlserver://servername:1433;DatabaseName=db_Scenince;user=sa;password=123";
    改成:
    url="jdbc:microsoft:sqlserver://"+servername+":1433:databasename=db_Scenince;user=sa;password=123";