`
JaHunter
  • 浏览: 89545 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

HttpSession session = request.getSession(false)

    博客分类:
  • java
阅读更多

  getSession  
  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.    
   
  To   make   sure   the   session   is   properly   maintained,   you   must   call   this   method   before   the   response   is   committed.   If   the   container   is   using   cookies   to   maintain   session   integrity   and   is   asked   to   create   a   new   session   when   the   response   is   committed,   an   IllegalStateException   is   thrown.  
   
  Parameters:  
  true   -   to   create   a   new   session   for   this   request   if   necessary;   false   to   return   null   if   there's   no   current   session  
  Returns:  
  the   HttpSession   associated   with   this   request   or   null   if   create   is   false   and   the   request   has   no   valid   session

分享到:
评论

相关推荐

    cookie后台操作

    HttpSession session = request.getSession(false); if (session != null) session.removeAttribute(USER_SESSION); Cookie cookie = cookieUtils.delCookie(request); if (cookie != null) response....

    比较简单的添加购物车,不过只有一个小程序

    HttpSession session=request.getSession(); ShopCart cart=(ShopCart)session.getAttribute("cart"); if(cart==null){ cart=new ShopCart(); session.setAttribute("cart", cart); } String id=...

    java小项目

    HttpSession session = request.getSession(); session.setAttribute("userName", name); session.setAttribute("pwd", pwd); session.setAttribute("msgList", msgList); response.sendRedirect("jspPages/...

    用户管理系统(ums)

    HttpSession session= request.getSession(); // 设置session的值 session.setAttribute("userList", list); //跳转到显示的页面,格式(得到当前页面的+要跳转的页面) response.sendRedirect(request....

    网上购物系统设计与实现

    HttpSession session=request.getSession(); CartBean cb=new CartBean(); Vector<CartProduct> cart =(Vector)session.getAttribute("cart"); String id=request.getParameter("id"); if(cart==null){ cart=...

    jsp基础精华详解

    HttpSession session = request.getSession(); session.setAttribute("name", "zhangsan"); session.setAttribute("pwd", "aaa"); String name = (String) session.getAttribute("name"); 2.cookie: //创建Cookie ...

    购物网站系统

    HttpSession session = request.getSession(false); String cusername=(String) session.getAttribute("cusername"); ContentInfobiz contentInfobiz=new ContentInfobiz(); int c=contentInfobiz.addcont(c...

    Java类写的随机验证码

    1、在JSP页面中用标记应用验证码。 <img alt="" src=...HttpSession session = request.getSession(); String rancode = (String)session.getAttribute("random"); if(code.equals(rancode)){//判断用户输入的对否

    登录过滤器

    HttpSession session = request.getSession(); //是否登录 //开放注册页面 if(null==session.getAttribute("merchantInfo") &&request.getRequestURL().indexOf("regist/merchant/acount.jsp")==-1){ ...

    数据库测试test.sql

    HttpSession session = request.getSession(); // session.setAttribute("username",username); session.setAttribute("user",user); //response.sendRedirect("/myservlet2/admin/success.jsp"); //response....

    jxl Java导出Excel文件jar 包

    HttpSession session = request.getSession(); //读取学生集合 List<Student> students = (List) session .getAttribute("students"); //读取学生编号集合 List<String> stuid =(List<String> )...

    实践考核类课二 选课系统

    HttpSession session=request.getSession(true); String stuid=(String) session.getAttribute("usr"); String[] list=request.getParameterValues("chooselist"); for(int count=0;count<list.length;count++){...

    Struts2_TypeConvertion

    A.Map session=ActionContext.getSession(); B.Map session=(Map)ActionContext.getContext().get(ActionContext.SESSION); 得到这个SessionMap之后我们就可以对session进行读写了,如果我们想得到原始的...

    jsp 对request.getSession(false)的理解(附程序员常疏忽的一个漏洞)

    【官方解释】 getSession 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 ...

    新闻发布系统

    HttpSession session = request.getSession(); // 获取session对象 PrintWriter out = response.getWriter(); // 获取out对象(响应输出字符流) ServletContext application = super.getServletContext(); // ...

    jsp 验证码 控件

    HttpSession session=request.getSession(true); response.setContentType("image/jpeg"); response.addHeader("pragma", "NO-cache"); response.addHeader("Cache-Control", "no-cache"); response....

    jsp+struts权限管理

    HttpSession hs = ServletActionContext.getRequest().getSession(); ff.newFunction(f, (Integer) hs.getAttribute("mid")); return Action.SUCCESS; } // 处理findFunction请求的方法 @SuppressWarnings(...

    struts2 session 解读

    例: public String findAll(){ HttpSession session = ServletActionContext.getRequest().getSession(); list = userService.find(); session.setAttribute(“list”, list); return this.SUCCESS;

    struts乱码问题

    HttpSession session=request.getSession(); session.setAttribute("bookName", this.bookName); session.setAttribute("bookPrice", this.bookPrice); session.setAttribute("bookPress", this.bookPress); ...

    jsp+Servlet实现简单的登陆

    Servlet+Jsp实现简单的登陆,HttpSession session = request.getSession();

Global site tag (gtag.js) - Google Analytics