`

Session 使用

    博客分类:
  • j2ee
阅读更多

Session是在服务器端创建的:

HttpSession session = request.getSession();

 

设置session里面的值:

session.setAttribute("code", "值");

 

取得session里面的值;

String code =  session.getAttribute("code");

 

判断是否已经创

        if (session.isNew()) {

             response.getWriter().print("session创建成功,session的id是:"+sessionId);

         }else {

             response.getWriter().print("服务器已经存在该session了,session的id是:"+sessionId);

         }

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics