request.getSession.setAttribute()是获得当前会话的session,然后再setAttribute到session里面去,有效范围是session而不是request。

而request.setAttribute()是setAttribute到request中去。有效范围是request。

session在一次会话期内有效,比如:訪问一个论坛,登陆后,你的username等信息被保存到session中,在session过期之前或你关闭这个网页前。username信息都能够通过request.getSession().getAttribute()方式获得。 request在当次的请求的url之间有效,比如。你请求某个servlet,那么你提交的信息,能够使用request.getAttribute()方式获得。而当你再次跳转后,这些信息将不存在。

request.getSession().setAttribute("",..)和request.setAttribute("",...)的差别的更多相关文章

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

    出处:http://blog.csdn.net/xxd851116/archive/2009/06/25/4296866.aspx [前面的话] 在网上经常看到有人对request.getSessio ...

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

    本文属于本人原创,转载请注明出处:http://blog.csdn.net/xxd851116/archive/2009/06/25/4296866.aspx [前面的话] 在网上经常看到有人对req ...

  3. 如何获得 request, "request.getSession(true).setAttribute("a",a);"与“request.setAttribute("a",a);”区别

    protected ServletContext getServletContext() { return ServletActionContext.getServletContext();} pro ...

  4. HttpServletRequest中的request.setAttribute()和request.getSession().setAttribute()

    request.setAttribute("num",value):有效范围是一个请求范围,不发送请求的界面无法获取到value的值,jsp界面获取使用EL表达式${num}:re ...

  5. JSP内置对象---request对象(用户登录页面(setAttribute))

    在上节 request.jsp 中 添加脚本语句: <% request.setAttribute("password", "123456"); %> ...

  6. 转:request.getSession(true)和request.getSession(false)的区别

    1.转自:http://wenda.so.com/q/1366414933061950?src=150 概括: request.getSession(true):若存在会话则返回该会话,否则新建一个会 ...

  7. (转)request.getSession()几种获取情况之间的差异

    一.三种情况 HttpSession session = request.getSession(); HttpSession session = request.getSession(true); H ...

  8. 关于request.getsession(true|false)

    request.getSession(true):若存在会话则返回该会话,否则新建一个会话.request.getSession(false):若存在会话则返回该会话,否则返回NULL

  9. request.getSession();为什么不用response儿用request!

    首先回答为什么分别是response和request这两个内置对象.你得先明白你通过获取对象是做什么用的,是往哪用的.第一个PrintWriter out=response.getWriter()是想 ...

随机推荐

  1. react父子组件数据传递

    子传父 1.首先父组件设定一个自定义函数 getChildDatas = (values) => { //...业务代码 } 2.将该函数暴露在子组件的引用上 <Child getChil ...

  2. Android 菜单键和返回键互换

    打开RE管理器找到system/usr/keylayout/ 长按qwerty.kl选择以文本编辑器查看 将里面的MENU和BACK全部替换掉 保存,退出管理器,重启手机,菜单键和返回键的位置就调换过 ...

  3. 【Go入门教程9】并发(goroutine,channels,Buffered Channels,Range和Close,Select,超时,runtime goroutine)

    有人把Go比作21世纪的C语言,第一是因为Go语言设计简单,第二,21世纪最重要的就是并行程序设计,而Go从语言层面就支持了并行. goroutine goroutine是Go并行设计的核心.goro ...

  4. .NET:CLR via C# Primitive Thread Synchronization Constructs

    User-Mode Constructs The CLR guarantees that reads and writes to variables of the following data typ ...

  5. window.open("url?param="+paramvalue) 服务端 乱码问题解决

    window.open("url?param="+paramvalue)传递参数出现乱码,在客房端显示是正常的,可是到服务端就是乱码. 1. 利用一个js在客户端转码的函数,esc ...

  6. Java 8 的新特性和改进总览

    这篇文章是对Java 8中即将到来的改进做一个面向开发者的综合性的总结,JDK的这一特性将会在2013年9月份发布. 在写这篇文章的时候,Java 8的开发工作仍然在紧张有序的进行中,语言特新和API ...

  7. 使用 SVWebViewController 推出浏览器控制器

    SVWebViewController 简单翻译 https://github.com/samvermette/SVWebViewController SVWebViewController is a ...

  8. java获取路径(转)

    1.利用System.getProperty()函数获取当前路径:System.out.println(System.getProperty("user.dir"));//user ...

  9. dao层的泛型实现(2种方法)

    一: package com.wzs.test2.dao; import java.util.List; public interface CommonDAO { public <T> v ...

  10. Android 项目的代码混淆,Android proguard 使用说明

    简单介绍 Java代码是非常easy反编译的. 为了非常好的保护Java源码,我们往往会对编译好的class文件进行混淆处理. ProGuard是一个混淆代码的开源项目.它的主要作用就是混淆,当然它还 ...