Session 和 Cache 的比较

    简单点说
    Session   是对针对单个连接来使用的,例如一些登陆用户的信息;  
    Cache   是对全局来定的,例如某些子控件地重复使用,广告等。

Session 在使用中还有一些比较迷惑的地方

HttpSession session =  request.getSession() 与 HttpSession  session =  request.getSession(true)

有何区别?   
    
  二者在效果上没有区别。request.getSession()会自动调用request.getSession(true)。  
 
  request.getSession(boolean create)  
      如果有与当前的request相关联的HttpSession,那么返回与当前request关联的HttpSession,  
      如果还没有,那么:  
      如果   create   ==   true   那么返回一个新建的HttpSession;  
      如果   create   ==   false,那么返回   null。  

 

原文地址:https://www.cnblogs.com/eoiioe/p/1140847.html