因为JSP初始化的时候就把SESSION初始化好了,这句话错了!要通过 HttpSession session = New HttpSession();这样才能访问Session!

解决方案 »

  1.   

    in servlet:
     HttpSession session=request.getSession();
     session.getAttribute("sessVal");
      

  2.   

    request.getSession().getAttribute("SessionVarName");
      

  3.   

    HttpSession session=request.getSession();
     session.getAttribute("sessVal");就这么写了
      

  4.   

    HttpSession session=request.getSession(true);
    strMobileNumber = session.getAttribute("mobile_num");
      

  5.   

    HttpSession session=request.getSession(true);
    strMobileNumber = session.getAttribute("mobile_num");
    中的request.getSession(true); 这个TRUE 和 FALSE传进去这两个参数有什么区别
      

  6.   

    HttpSession httpsession = httpservletrequest.getSession();
      

  7.   

    问题又来了,加上 HttpSession httpsession = httpservletrequest.getSession();
    中传入参数 true和false和不传参数,有什么区别
      

  8.   

    public HttpSession getSession(boolean create)Returns the current HttpSession associated with this request or, if if there is no current session and create is true, returns a new session. If create is false and the request has no valid HttpSession, this method returns null.这几句英文搞不定那搞软件可就比较难了!
      

  9.   

    在SERVLET中加入
    HttpSession httpsession = HttpServletRequest.getSession();