0

tomcat session.invalidate problem

asked 2007-04-04 04:02:27 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4242535

By: stonegu

I'm doing some performance testing on an jsp & servlet based application that uses ZK framework. Everything is ok when I just use jsp & servlet, but when I installed ZK into my application (copy zk's web.xml into my application's web.xml and put zk's jars into tomcat's lib just like docs said), I start to see the following error when I logoff from my application.

----- Error Info -----

java.lang.IllegalStateException: Cannot create a session after the response has been committed
org.apache.catalina.connector.Request.doGetSession(Request.java:2214)
org.apache.catalina.connector.Request.getSession(Request.java:2024)
org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:831)
org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:842)
org.zkoss.zk.ui.http.WebManager.getSession(WebManager.java:324)
org.zkoss.zk.ui.http.DHtmlLayoutFilter.process(DHtmlLayoutFilter.java:78)
org.zkoss.zk.ui.http.DHtmlLayoutFilter.doFilter(DHtmlLayoutFilter.java:105)

----- End -----

----- System Info -----

WinXP, Tomcat 5.5, ZK 2.2.1

----- End -----

----- Code for Sign out ----

<%
if (request.getParameter("logoff") != null) {
session.invalidate();
response.sendRedirect("myallonline.jsp?ordercol=m_datetime&sort=desc");
return;
}
%>

----- End -----

I did some research on the net, and was told that the problem maybe in
session.invalidate() or response.sendRedirect, but I can't find any solution.

Any suggestion will be highly appreciated!


delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2007-04-05 15:08:13 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4245098

By: jumperchen

Hi,

It works fine for me.
Could you provide more information about your code.

Thanks

Jumper

link publish delete flag offensive edit

answered 2007-04-07 03:29:06 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4248611

By: stonegu

Thanks Jumper, more details are here:

I have one jsp page, I call it myallonline.jsp:

----- code for myallonline.jsp ------
...
<%
if (request.getParameter("logoff") != null) {
session.invalidate();
response.sendRedirect("myallonline.jsp?ordercol=m_datetime&sort=desc");
return;
}
%>
...
<html xmlns="http://www.w3.org/1999/xhtml">
...
<a href='<%= response.encodeURL("myallonline.jsp?logoff=true") %>'>Sign out.</a> ...
</html>
----- End -----

Problem:

Everytime I click "Sign out" in myallonline.jsp, I get next error message:

----- Error Info -----

java.lang.IllegalStateException: Cannot create a session after the response has been committed
org.apache.catalina.connector.Request.doGetSession(Request.java:2214)
org.apache.catalina.connector.Request.getSession(Request.java:2024)
org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:831)
org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:842)
org.zkoss.zk.ui.http.WebManager.getSession(WebManager.java:324)
org.zkoss.zk.ui.http.DHtmlLayoutFilter.process(DHtmlLayoutFilter.java:78)
org.zkoss.zk.ui.http.DHtmlLayoutFilter.doFilter(DHtmlLayoutFilter.java:105)

----- End -----

I already find a solution for this, I redirect url to another page (for example <a href='<%= response.encodeURL("logout_confirm.jsp?logoff=true") %>'>Sign out.</a>) instead of same page (<a href='<%= response.encodeURL("myallonline.jsp?logoff=true")
%>'>Sign out.</a>), and kill the session in logout_confirm.jsp

----- code in logou_confirm.jsp -----
<%
if (request.getParameter("logoff") != null) {session.invalidate();}
if (request.getSession(false) == null){session=request.getSession(true);}
else{session=request.getSession(false);}
%>
----- End -----

Any suggestion...

Thanks

Stone

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2007-04-04 04:02:27 +0800

Seen: 1,077 times

Last updated: Apr 07 '07

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More