[opencms-dev] OpenCms 8 Login / Logout

Georgi Naplatanov gosho at oles.biz
Tue Sep 25 12:23:50 CEST 2012


Hi Sandrine.

This error means that you try to manage session after the response to 
the client/browser so maybe you have to move this code at the top of 
your template and be sure that there are not HTML tags neither white 
spaces before <% tag.

On the other hand Apache Tomcat inserts empty lines for every <% tag, so 
put them in one line:

<%@ page session="false" contentType="text/html;charset=UTF-8" 
language="java" import="java.util.Enumeration, org.opencms.jsp.*" %><%@ 
taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" 
%><cms:template element="head"><%
#your session code#
%><?xml version="1.0" encoding="utf-8"?>
.....

Best regards
Georgi

On 09/25/2012 11:57 AM, Sandrine Prousteau wrote:
> Hi!
> I'm on OpenCms 8.0.4, and I try to have a jsp included at the top of my page to manage login/logout for my site's users before displaying the content of the page.
>
> I have this error when I do :
>
> <jsp:useBean id="bean" class="org.opencms.jsp.CmsJspLoginBean"><% bean.init(pageContext, request, response); %></jsp:useBean>
> if(!bean.isLoggedIn()){
>    ...
> }else{
>    try {
>      String paramLogout = org.opencms.util.CmsRequestUtil.getNotEmptyParameter(request, org.opencms.workplace.CmsLogin.PARAM_ACTION_LOGOUT);
>      if (Boolean.valueOf(paramLogout).booleanValue()){
>        bean.logout();
>        LOG.debug("LOGIN-LOGOUT : bean.logout();");
>      }
>    } catch (Exception e) {
>    LOG.error("LOGIN-LOGOUT : "+e);
>    }
> }
>
> 25 Sep 2012 11:01:43,349 ERROR [opencms.jsp.CmsJspTagContainer: 359] 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.catalina.connector.Request.doGetSession(Request.java:2734)
> 	at org.apache.catalina.connector.Request.getSession(Request.java:2244)
> 	at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:899)
> 	at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:229)
> 	at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:572)
> 	at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:517)
> 	at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:238)
> 	at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:238)
> 	at org.opencms.jsp.CmsJspTagContainer.getSessionCache(CmsJspTagContainer.java:744)
> 	at org.opencms.jsp.CmsJspTagContainer.renderContainerElement(CmsJspTagContainer.java:847)
> 	at org.opencms.jsp.CmsJspTagContainer.doStartTag(CmsJspTagContainer.java:356)
>
> How can I avoid this?
> Thank in advance.
> Sandrine.
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev
>
>
>



More information about the opencms-dev mailing list