vgritsenko 2004/05/05 10:08:05
Modified: src/java/org/apache/cocoon/components/flow/javascript/fom FOM_JavaScriptInterpreter.java Log: Check for valid session. Fixes exception running in Tomcat: ERROR (2004-05-05) 12:06.15:469 [sitemap.handled-errors] (/cc/samples/blocks/slide/logout.do) http8080-Processor5/PipelineNode: Cannot create a session after the response has been committed java.lang.IllegalStateException: Cannot create a session after the response has been committed at org.apache.coyote.tomcat5.CoyoteRequest.doGetSession(CoyoteRequest.java:2281) Revision Changes Path 1.29 +13 -9 cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java Index: FOM_JavaScriptInterpreter.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- FOM_JavaScriptInterpreter.java 5 May 2004 16:00:11 -0000 1.28 +++ FOM_JavaScriptInterpreter.java 5 May 2004 17:08:05 -0000 1.29 @@ -376,16 +376,20 @@ */ private Scriptable setSessionScope(Scriptable scope) throws Exception { Request request = ContextHelper.getRequest(this.avalonContext); - Session session = request.getSession(true); - HashMap userScopes = (HashMap)session.getAttribute(USER_GLOBAL_SCOPE); - if (userScopes == null) { - userScopes = new HashMap(); - session.setAttribute(USER_GLOBAL_SCOPE, userScopes); - } + // Check that session is available (avoids IllegalStateException) + if (request.isRequestedSessionIdValid()) { + Session session = request.getSession(true); + + HashMap userScopes = (HashMap)session.getAttribute(USER_GLOBAL_SCOPE); + if (userScopes == null) { + userScopes = new HashMap(); + session.setAttribute(USER_GLOBAL_SCOPE, userScopes); + } - // Attach the scope to the current context - userScopes.put(getSitemapPath(), scope); + // Attach the scope to the current context + userScopes.put(getSitemapPath(), scope); + } return scope; }