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

Cannot create a session after the response has been committed

阅读更多

本文引自:http://chenkuning.iteye.com/blog/642106   仅作收藏,别无他意

某jsp include另一个jsp之后偶尔报错:Cannot create a session after the response has been committed

google之后发现可能是session的创建时机不对,不应该在include的jsp里面创建session(并没有显示调用request.getSession(),但jsp页面默认有pageContext.getSession()的),如是在当前页面中加入:request.getSession();既然时机不对,那么在加入到当前页面中时就创建session,被include的jsp中就不需要创建了。OK, 一切正常。

 

"Cannot create a session after the response has been committed的根本原因并不再request.getSession(),而是在jsp开头的<%@ page session="false" %>",boss发话了。boss今天咋这么闲,连jsp都不放过,之前只有在修改了framework才会有机会聆听教导的。行,那我改改。

 

于是去掉当前页面中的<%@ page session="false" %>,这样在访问当前页面时就创建session,include的jsp中再创建(实际上是获取)session就没有问题了。测试OK, 一切正常。

 

"除了去掉<%@ page session="false" %>还有其他的方案吗?",boss又发话了。"在当前页面和被include的页面中都加入<%@ page session="false" %>应该也可以解决问题。......","那你觉得为什么要禁用session呢?", "......", "

有session的页面有可能会影响到缓存,本来是一个可以缓存的页面,加上session就不能缓存了"。

 

session和缓存有什么关系?只得暂时将当前页面和include页面都加入<%@ page session="false" %>,以确保不出现不过&&可缓

分享到:
评论

相关推荐

    Cannot forward after response has been committed

    NULL 博文链接:https://m635674608.iteye.com/blog/1510545

    a project model for the FreeBSD Project.7z

    this document will outline the organisational structure (including role descriptions and communication lines), discuss the methodology model and after presenting the tools used for process control, ...

    Git-2.21.0-64-bit.zip

    otherwise no need to create a new merge and replace the existing one (i.e. fast-forward instead), but did not. Which has been corrected. * Code cleanup and futureproof. * More parameter ...

    微软内部资料-SQL性能优化2

    If you attempt to access a reserved address that has not yet been committed (backed by memory or disk) you will cause an access violation. Committed Memory Committed pages are those pages that when ...

    servlet2.4doc

    Returns a boolean indicating whether the named response header has already been set. contextDestroyed(ServletContextEvent) - Method in interface javax.servlet.ServletContextListener Notification ...

    微软内部资料-SQL性能优化3

    For example, a second transaction traversing the doubly linked list mentioned above would see the list before or after the insert, but it will see only complete changes. Durability After a ...

    SessionPage 0.1.7 Stable Released. Committed to AMC.

    version 0.1.7. Now much more stable and stable. welcome to try. please rename the file ext to \"xpi\". 博文链接:https://babyheart.iteye.com/blog/44619

    google repo工具

    To make edits to changes after they have been uploaded, you should use a tool like git rebase -i or git commit --amend to update your local commits. After your edits are complete: Make sure the ...

    Django 1.1 Testing and Debugging.pdf

    What if a fix hasn't been committed yet? 366 What if a ticket has been closed without a fix? 367 Tracking down unreported problems 368 Where to ask questions 369 Tips on asking questions that will...

    HttpWebRequest出错.Section=ResponseHeader Detail=CR

     Section=ResponseHeader Detail=CR 后面必须是 LF The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF 主体意思是微软没有容忍不符合RFC 822...

    Paul Ekman - Unmasking The Face. A guide to recognizing emotions from facial clues.part1.rar

    Ekman is a leading authority on the study of the facial expressions and their relation to emotion, and this book is a methodical and thorough (for the layperson, at least) introduction to the field, ...

    Paul Ekman - Unmasking The Face. A guide to recognizing emotions from facial clues.part2.rar

    Ekman is a leading authority on the study of the facial expressions and their relation to emotion, and this book is a methodical and thorough (for the layperson, at least) introduction to the field, ...

    Microsoft ASP.NET and AJAX: Architecting Web Applications

    Everybody in the industry is committed to AJAX. Everybody understands the impact of it. Everybody recognizes the enormous power that can be derived from its employment in real-world solutions. Very ...

    curl for windows10 x64

    curl for windows10 x64 , version Version 7.56.1 (23 Oct 2017) Daniel Stenberg (23 Oct 2017) - RELEASE-NOTES: 7.56.1 ...- imap: if a FETCH response has no size, don't call write callback

    Developer Express XtraGrid Suite All Sources Code

    released the first version of the XtraGrid Suite, our focus has been to deliver ground-breaking new capabilities for Visual Studio .NET&reg;. With XtraGrid Suite v2, you have at your disposal a ...

    Unity.5.x.Game.AI.Programming.Cookbook.17835

    He has committed the last four years to game development working in various positions; from tool developer, to lead programmer. His main focus is AI and gameplay programming, and currently he works ...

Global site tag (gtag.js) - Google Analytics