On 7/4/05, Michael Wiedmann <[EMAIL PROTECTED]> wrote:
> If the session timeout value expires (default: 30 min.) the user should
> be redirected to the login page. This worked until some time in the past
> but now (using myfaces 1.0.8, Tomcat 5.0.30) we notice the following:
>
> We have a code fragment which checks for a session attribute "loginname"
> and if this check results in "null" (because the session has expired or
> the user has not yet successfully logged in) we want to redirect him
> using "jsp:forward":
>
> <%
> String _loginname = (String)session.getAttribute("loginname");
> if (_loginname == null)
> {
> %>
> <jsp:forward page="/faces/jsp/login.jsp" />
> <%}%>
>
> The check itself works but the attempt to redirect results in a:
>
> java.lang.IllegalStateException: Error: Attempt to clear a buffer \
> that's already been flushed
If a session has been marked invalidated, you'll get
IllegalStateException, not null, when using getAttribute.
http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/http/HttpSession.html#getAttribute(java.lang.String)
Unfortunately, the only way to detect if a session is invalidated is
to catch IllegalStateException.
-Mike