• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >JSP > jsp 对request.getSession(false)的理解(附程序员常疏忽的一个漏洞)

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

作者: 字体:[增加 减小] 来源:互联网 时间:2017-05-11

通过本文主要向大家介绍了jsp中request的用法,jsp获取request参数,jsp中request,jsp获取request值,jsp获取request对象等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
【前面的话】
在网上经常看到有人对request.getSession(false)提出疑问,我第一次也很迷惑,看了一下J2EE1.3 API,看一下官网是怎么解释的。
【官方解释】
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
译:
getSession(boolean create)意思是返回当前reqeust中的HttpSession ,如果当前reqeust中的HttpSession 为null,当create为true,就创建一个新的Session,否则返回null;
简而言之:
HttpServletRequest.getSession(ture) 等同于 HttpServletRequest.getSession()
HttpServletRequest.getSession(false) 等同于 如果当前Session没有就为null;
【问题和bug】:
我周围很多同事是这样写的;
来源:http://blog.csdn.net/xxd851116 </div>
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • jsp Request获取url信息的各种方法对比
  • JSP利用过滤器解决request中文乱码问题
  • jsp 对request.getSession(false)的理解(附程序员常疏忽的一个漏洞)

相关文章

  • 2017-05-11JSP开发入门(三)--JSP与JavaBean
  • 2017-05-11JDBCTM 指南:入门5 - ResultSet
  • 2017-05-11用JSP编写通用信息发布程序
  • 2017-05-11JSP内置对象:Request和Response的简单介绍及使用
  • 2017-05-11JSP学习之Servlet用法分析
  • 2017-05-11jsp页面调用applet实现人民币的大小写转换
  • 2017-05-11jsp传值本地无乱码测试机出现乱码问题解决
  • 2017-05-11建立JSP操作以提高数据库访问的效率
  • 2017-05-11邮件发送简单例子-html文件
  • 2017-05-11JSP response对象实现文件下载的两种方式

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • 在Windows/NT上建立JSP环境
    • jsp项目中更改tomcat的默认index.jsp访问路径的方法
    • 用简单的代码来实现文件上传
    • jsp 自定义标签实例
    • JSP application(return String)用法详例
    • Http请求长时间等待无结果返回解决办法
    • weblogic 8.1下重新编译java类但不用重启服务器的方法
    • jsp内置对象
    • jsp中文乱码 jsp mysql 乱码的解决方法
    • Java Web开发之图形验证码的生成与使用方法

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有