HTTP Status 500 - --------------------------------------------------------------------------------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:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause java.lang.NullPointerException
org.apache.jsp.isLogin_jsp._jspService(isLogin_jsp.java:77)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.大家帮忙看看把,烦了几天啦~~

解决方案 »

  1.   

    如果我从login.jsp进去,就会又类错误
    HTTP Status 500 - --------------------------------------------------------------------------------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:372)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause java.lang.NullPointerException
    myapp.User.userExist(User.java:55)
    org.apache.jsp.isLogin_jsp._jspService(isLogin_jsp.java:80)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
    就会报我的user.java错误,我的user.java是这样的:
    package myapp;import java.sql.*;/**
     * <p>用户登录管理类</p>
     */
    public class User {
      private String username; //登录用户名称
      private String loginIP; //用户IP  private String loginDateTime; //用户登录日期时间
      public User() {
        username = "";
        loginIP = "";
        loginDateTime = "";
      }  public String getUsername() {
        return username;
      }  public void setUsername(String user) {
        username = user;
      }  public String getLoginIP() {
        return loginIP;
      }  public void setLoginIP(String userIP) {
        loginIP = userIP;
      }  public String getLoginDateTime() {
        return loginDateTime;
      }  public void setLoginDateTime(String currentDateTime) {
        loginDateTime = currentDateTime;
      }  //检查用户是否存在
      public boolean userExist(String username) {
        Connection con = null;
        Statement stmt = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        boolean exist = false;
        String sql = "select * from userLogin where username=?"; //构造查询sql语句
        DBConnection dbConnection = new DBConnection();
        dbConnection.getConnection();
        try {
          con = dbConnection.con;
          ps = con.prepareStatement(sql);
          ps.setString(1, username);
          rs = ps.executeQuery();
          if (!rs.next()) {
            exist = true;
          }
        }
        catch (SQLException e) {
          e.printStackTrace();
        }
        finally {
          dbConnection.closeConn();
        }
        return exist;
      }  //判断用户是否合法
      public boolean isValidUser(String username, String password) {
        Connection con = null;
        Statement stmt = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        boolean isValid = false;
        String sql = "select * from userLogin where username=? and password=?"; //构造查询sql语句
        DBConnection dbConnection = new DBConnection();
        dbConnection.getConnection();
        try {
          con = dbConnection.con;
          ps = con.prepareStatement(sql);
          ps.setString(1, username);
          ps.setString(2, password);
          rs = ps.executeQuery();
          if (rs.next()) {
            isValid = true;
          }
        }
        catch (SQLException e) {
          e.printStackTrace();
        }
        finally {
          dbConnection.closeConn();
        }
        return isValid;
      }  //获取用户编号ID
      public int userID(String username, String password) {
        Connection con = null;
        Statement stmt = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        int id = 0;
        String sql = "select id from userLogin where username=? and password=?"; //构造查询sql语句
        DBConnection dbConnection = new DBConnection();
        dbConnection.getConnection();
        try {
          con = dbConnection.con;
          ps = con.prepareStatement(sql);
          ps.setString(1, username);
          ps.setString(2, password);
          rs = ps.executeQuery();
          if (rs.next()) {
            id = rs.getInt("id");
          }
        }
        catch (SQLException e) {
          e.printStackTrace();
        }
        finally {
          dbConnection.closeConn();
        }
        return id;
      }  //获取用户权限
      public String userRights(String username, String password) {
        Connection con = null;
        Statement stmt = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String rights = null;
        String sql = "select rights from userLogin where username=? and password=?"; //构造查询sql语句
        DBConnection dbConnection = new DBConnection();
        dbConnection.getConnection();
        try {
          con = dbConnection.con;
          ps = con.prepareStatement(sql);
          ps.setString(1, username);
          ps.setString(2, password);
          rs = ps.executeQuery();
          if (rs.next()) {
            rights = rs.getString("rights");
          }
        }
        catch (SQLException e) {
          e.printStackTrace();
        }
        finally {
          dbConnection.closeConn();
        }
        return rights;
      }  //记录用户登录信息
      public void setUserLoginInfo(String currentDateTime, String userIP,
                                   String username) {
        Connection con = null;
        Statement stmt = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String sql =
            "update userLogin set loginDateTime = ? ,loginIP= ? where username = ?"; //构造更新sql语句
        DBConnection dbConnection = new DBConnection();
        dbConnection.getConnection();
        try {
          con = dbConnection.con;
          ps = con.prepareStatement(sql);
          ps.setString(1, currentDateTime);
          ps.setString(2, userIP);
          ps.setString(3, username);
          ps.executeUpdate();
        }
        catch (SQLException e) {
          e.printStackTrace();
        }
        finally {
          dbConnection.closeConn();
        }
      }  //记录用户登录日志(登录)
      public void saveUserLoginLog(String username, String loginDateTime) {
        Connection con = null;
        Statement stmt = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String sql = "insert into userLoginLog(username,loginDateTime) values(?,?)"; //构造插入sql语句
        DBConnection dbConnection = new DBConnection();
        dbConnection.getConnection();
        try {
          con = dbConnection.con;
          ps = con.prepareStatement(sql);
          ps.setString(1, username);
          ps.setString(2, loginDateTime);
          ps.executeUpdate();
        }
        catch (SQLException e) {
          e.printStackTrace();
        }
        finally {
          dbConnection.closeConn();
        }
      }  //记录用户登录日志(退出)
      public void saveUserLoginOutLog(String loginOutDateTime, String username) {
        Connection con = null;
        Statement stmt = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String sql =
            "update userLoginOut set loginOutDateTime = ? ,where username = ?"; //构造更新sql语句
        DBConnection dbConnection = new DBConnection();
        dbConnection.getConnection();
        try {
          con = dbConnection.con;
          ps = con.prepareStatement(sql);
          ps.setString(1, loginOutDateTime);
          ps.setString(2, username);
          ps.executeUpdate();
        }
        catch (SQLException e) {
          e.printStackTrace();
        }
        finally {
          dbConnection.closeConn();
        }
      }  //获取当前日期时间
      public String getCurrentDateTime() {
        String loginDateTime = null;
        java.util.Date DateTime = new java.util.Date(); //设置日期时间格式
        java.text.SimpleDateFormat currentDateTime = new java.text.SimpleDateFormat(
            "yyyy-MM-dd hh:mm:ss");
        loginDateTime = currentDateTime.format(DateTime); //获取当前日期时间
        return loginDateTime;
      }
    }谢谢帮忙看看把