java.lang.IllegalStateException:响应提交后无法创建会话 [英] java.lang.IllegalStateException: Cannot create a session after the response has been committed

查看:1809
本文介绍了java.lang.IllegalStateException:响应提交后无法创建会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 无效的网址:/ cgi-bin / 1st .cgi 

这是导致以下错误:

  SEVERE:异常初始化页面上下文
java.lang.IllegalStateException:在org.apache.catalina.connector提交响应后无法创建会话
.Request.doGetSession(Request.java:2381)
在org.apache.catalina.connector.Request.getSession(Request.java:2098)
在org.apache.catalina.connector.RequestFacade.getSession (RequestFacade.java:833)
在javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
在org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544 )
...

如何解决这个问题?

解决方案

发生的是re响应流已关闭。你已经发送了一个重定向,或者提交了一些其他类型的响应。我建议在执行任何响应之前获取会话对象,并保存响应,直到没有任何事情与 HttpServletRequest HttpServletResponse 对象



一个好的做法是在执行重定向后立即从Servlet返回,这样可以避免这些问题。 >

I've got this really strange request for an invalid URL on:

Invalid URL: /cgi-bin/1st.cgi

This is causing the following error:

 SEVERE: Exception initializing page context
java.lang.IllegalStateException: Cannot create a session after the response has been committed
        at org.apache.catalina.connector.Request.doGetSession(Request.java:2381)
        at org.apache.catalina.connector.Request.getSession(Request.java:2098)
        at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
        at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
        at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)
...

How can I solve this issue?

解决方案

What's happening is the response stream has been closed. Either you already sent a redirect, or committed some other type of response. I recommend getting your session object before you perform any response, and save the response until there is nothing left to do with the HttpServletRequest or HttpServletResponse objects.

A good practice is to return from your Servlet right away after performing a redirect, that way you can avoid some of these problems.

这篇关于java.lang.IllegalStateException:响应提交后无法创建会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆