空指针,是不是你的JSP中间用到了没有初始化的对象?

解决方案 »

  1.   

    public boolean checkSessionBean(HttpServletRequest request,String strSessionName,String strCheckValue){
    //public boolean checkSessionBean(HttpServletRequest request){
    HttpSession session = request.getSession(false);
    //return(bolCheckPass);
    // session.setAttribute("sesUserRole","user"); 
    if (strSessionName==null || strCheckValue==null){
    return(bolCheckPass);
    }else{
    if (session!=null && session.getAttribute(strSessionName)!=null){
    bolCheckPass=session.getAttributestrSessionName).equals(strCheckValue);
    }
    return(bolCheckPass);
    }
    }
    //session.setAttribute("sesUserRole","user"); 这一条语句加了就出错,出现上面的提示...
      

  2.   

    当然出错了,你看代码Session session=request.getSession(false);
    这个意思就是说要获得这个用户的Session,假如有便给他,假如没有也不新建一个给他,看Doc就是这样,没有那么返回null,所以才会出现空指针,改为session=request.getsession(true),或是不要参数,默认为true