-
1. Re: Sessiontimeout is not working in IE 8
nbelaevski Dec 24, 2009 6:46 AM (in response to tharves)Hi,
Please try upgrading to a later version (3.3.2.SR1/3.3.3.BETA1) and check
-
2. Re: Sessiontimeout is not working in IE 8
tharves Dec 25, 2009 8:09 AM (in response to nbelaevski)Hi Nick,
I tried, But it was not working. Please tell me where i made mistake
In this jsp page, I have created 4 tab and switchType="ajax" and one longout link(This is not ajax)
I have one filter class and listener class.
If i clicked logout page,In this filter class checking session. If session is invalidated, it will be moved to home page.
if
if (isSessionInvalid(httpServletRequest)) {
System.
out.println("coming Sessiin timeout");
String timeoutUrl =
"";
if (language != null && !language.equals("")) {
timeoutUrl = path +
"/" + language + "/"+ getTimeoutPage();
System.
out.println("Session timeout Filter class"+timeoutUrl);
httpServletResponse.sendRedirect(timeoutUrl);
return;
}
else {
timeoutUrl = path +
"/";
httpServletResponse.sendRedirect(timeoutUrl);
return;
(isSessionControlRequiredForThisResource(httpServletRequest)) {}
}
}
if i clicked any tab on client page. I am getting ajaxscript error. another one thing that filter indicated that session alos time out. But it can't redirect to home page.
I am getting following
Please help me.
-
3. Re: Sessiontimeout is not working in IE 8
nbelaevski Dec 25, 2009 5:08 PM (in response to tharves)Hi,
Your message seems to be corrupted, can you please resend it? Use ">>" button to insert placeholder for code.
-
4. Re: Sessiontimeout is not working in IE 8
tharves Dec 28, 2009 4:16 AM (in response to nbelaevski)
Hi Nick,I am getting following error. I herewith attached code also.
2009-12-26 11:41:03,029 ERROR - Exception occured while redirecting to session time out page
javax.servlet.ServletException: org.ajax4jsf.resource.ResourceNotFoundException: Resource not registered : org.ajax4jsf.javasctyle%3E%3C/head%3E%3Cbody%3E%3Cdiv%20id=%22skipLinks%22%20class=%22tools%22%3E%3Ca%20href=%22
at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:154)
at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:141)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:486)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.wipo.das.framework.util.SessionTimeoutFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:567)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.ajax4jsf.resource.ResourceNotFoundException: Resource not registered : org.ajax4jsf.javasctyle%3E%3C/head%3E%3Cbody%3E%3Cdiv%20id=%22skipLinks%22%20class=%22tools%22%3E%3Ca%20href=%22
at org.ajax4jsf.resource.ResourceBuilderImpl.getResource(ResourceBuilderImpl.java:389)
at org.ajax4jsf.resource.ResourceBuilderImpl.getResourceForKey(ResourceBuilderImpl.java:333)
at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:152)
... 18 more-
screenshot.docx 133.1 KB
-
TestListener.java.zip 494 bytes
-
sessionFilter.java.zip 422 bytes
-
login.jsp.zip 729 bytes
-
-
5. Re: Sessiontimeout is not working in IE 8
nbelaevski Dec 30, 2009 9:14 AM (in response to tharves)Please post web.xml contents also. -
6. Re: Sessiontimeout is not working in IE 8
veerat Apr 22, 2010 7:05 AM (in response to tharves)Hi Tharves,
I am also facing with same issue. If you Got any solution pls send me.I am getting the following JS error.
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; InfoPath.2)
Timestamp: Thu, 22 Apr 2010 07:33:46 UTC
Message: Object doesn't support this property or method
Line: 2583
Char: 12
Code: 0
URI: http://localhost:8080/a4j/g/3_2_2.GA/org/ajax4jsf/framework.pack.js.jsf -
7. Re: Sessiontimeout is not working in IE 8
ilya_shaikovsky Apr 22, 2010 9:23 AM (in response to veerat)please provide info Nick requested above for the case.
-
8. Re: Sessiontimeout is not working in IE 8
veerat Apr 22, 2010 10:39 AM (in response to ilya_shaikovsky)hi Ilya,
Thanks for your quick response.
Actually I want to maintain login session for my application.For that I have created one filter and redirecting to Login.jsf page.This is working fine for non-ajax requests. But in my application some ajax requests also there.How to maintain login session for ajax requests..?
I am using JSF 1.2 ,Facelets 1.1 & Richfaces 3.3.2
Here I am sending my code...
Web.xml
<? xml version="1.0" encoding="UTF-8"?> < web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name>Test</display-name> <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.xhtml</param-value> </context-param> <context-param> <param-name>facelets.REFRESH_PERIOD</param-name> <param-value>2</param-value> </context-param> <context-param> <param-name>facelets.DEVELOPMENT</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</param-value> </context-param> <context-param> <param-name>com.sun.faces.validateXml</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>com.sun.faces.verifyObjects</param-name> <param-value>false</param-value> </context-param> <context-param> <param-name>org.ajax4jsf.SKIN</param-name> <param-value>diEsdn</param-value> </context-param> <context-param> <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name> <param-value>com.sun.facelets.FaceletViewHandler</param-value> </context-param> <context-param> <param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>org.ajax4jsf.COMPRESS_STYLE</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>org.ajax4jsf.xmlparser.ORDER</param-name> <param-value>NEKO, TIDY</param-value> </context-param> <context-param> <param-name>org.richfaces.SKIN</param-name> <param-value>diEsdn</param-value> </context-param> <context-param> <param-name>org.richfaces.CONTROL_SKINNING</param-name> <param-value>enable</param-value> </context-param> <context-param> <param-name>org.richfaces.LoadStyleStrategy</param-name> <param-value>ALL</param-value> </context-param> <context-param> <param-name>org.richfaces.LoadScriptStrategy</param-name> <param-value>ALL</param-value> </context-param> <context-param> <param-name>org.ajax4jsf.handleViewExpiredOnClient</param-name> <param-value>true</param-value> </context-param> <filter> <display-name>Ajax4jsf Filter</display-name> <filter-name>ajax4jsf</filter-name> <filter-class>org.ajax4jsf.Filter</filter-class> <init-param> <param-name>createTempFiles</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>maxRequestSize</param-name> <param-value>100000</param-value> </init-param> </filter> <filter> <filter-name>SessionExpiredFilter</filter-name> <filter-class>com.tvr.filter.SessionExpiredFilter</filter-class> </filter> <filter-mapping> <filter-name>ajax4jsf</filter-name> <servlet-name>Faces Servlet</servlet-name> <dispatcher>FORWARD</dispatcher> <dispatcher>REQUEST</dispatcher> <dispatcher>INCLUDE</dispatcher> <dispatcher>ERROR</dispatcher> </filter-mapping> <filter-mapping> <filter-name>SessionExpiredFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>com.tvr.listener.SessionListener</listener-class> </listener> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> <session-config> <session-timeout>1</session-timeout> </session-config> <error-page> <exception-type>java.lang.Exception</exception-type> <location>/error.jsp</location> </error-page> <error-page> <error-code>500</error-code> <location>/error.jsp</location> </error-page> <login-config> <auth-method>BASIC</auth-method> </login-config> </ web-app>
SessionExpiredFilter.java
import java.io.IOException; import javax.faces.context.FacesContext; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class SessionExpiredFilter implements Filter { private String timeoutPage = "Login.jsf"; public void init(FilterConfig filterConfig) throws ServletException { } public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { if ((request instanceof HttpServletRequest) && (response instanceof HttpServletResponse)) { HttpServletRequest httpServletRequest = (HttpServletRequest) request; HttpServletResponse httpServletResponse = (HttpServletResponse) response; // is session expire control required for this request? if (isSessionControlRequiredForThisResource(httpServletRequest)) { // is session invalid? if (isSessionInvalid(httpServletRequest)) { String timeoutUrl = httpServletRequest.getContextPath() + "/" +getTimeoutPage();// "SearchUserForm.jsf"; System.out .println("Session is invalid! redirecting to timeoutpage :" + timeoutUrl); httpServletResponse.sendRedirect(timeoutUrl); return; } } filterChain.doFilter(request, response); } } /* * session shouldn’t be checked for some pages. For example: for timeout * page.. Since we’re redirecting to timeout page from this filter, if we * don’t disable session control for it, filter will again redirect to it * and this will be result with an infinite loop… */ private boolean isSessionControlRequiredForThisResource( HttpServletRequest httpServletRequest) { String requestPath = httpServletRequest.getRequestURI(); boolean controlRequired = !requestPath.contains(getTimeoutPage()); return controlRequired; } private boolean isSessionInvalid(HttpServletRequest httpServletRequest) { boolean sessionInValid = (httpServletRequest.getRequestedSessionId() != null) && !httpServletRequest.isRequestedSessionIdValid(); return sessionInValid; } public void destroy() { } public String getTimeoutPage() { return timeoutPage; } public void setTimeoutPage(String timeoutPage) { this.timeoutPage = timeoutPage; } } Login.xhtml <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> < html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> < head> < meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" /> < title>Login Page</title> </ head> < body> < f:view> <h:form id="loginForm"> <a4j:log/> <a4j:loadBundle var="msg" basename="ApplicationResources" /> <a4j:loadBundle var="errorMsgs" basename="MessageResources" /> <h:panelGrid columns="1"> <rich:panel style="width:350px;margin-top:70%;margin-left:70%;"> <f:facet name="header"> <h:outputText value="#{msg.login}" /> </f:facet> <h:panelGrid columns="2"> <h:messages style="font-weight:bold; color:red;"> </h:messages> </h:panelGrid> <h:panelGrid columns="2"> <h:outputText value="#{msg.username}" /> <h:inputText label="#{msg.username}" id="loginId" value="#{UserBean.loginId}" size="20" required="true" /> <h:outputText value="#{msg.password}" /> <h:inputSecret label="#{msg.password}" id="password" value="#{UserBean.password}" size="20" required="true" /> </h:panelGrid> <h:commandButton type="submit" value="Submit" action="#{UserBean.validateUser}" style="margin-left:20%;" /> <h:commandButton type="reset" value="Reset" /> </rich:panel> </h:panelGrid> </h:form> </ f:view> </ body> </ html>
EditUser.xhtml
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> < html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> < ui:composition> <f:view> <h:form> <a4j:loadBundle var="msg" basename="ApplicationResources" /> <a4j:loadBundle var="errorMsgs" basename="MessageResources" /> <h:panelGrid columns="1" width="100%"> <rich:panel width="100%"> <f:facet name="header"> <h:outputText value="User Form" style="text-align:right;" /> </f:facet> <h:panelGrid> <h:messages style="font-weight:bold; color:red;"> </h:messages> </h:panelGrid> <a4j:region> <h:panelGrid columns="3"> <font color="red">*</font> <h:outputText value="Login Name" /> <h:inputText id="loginName" value="#{userFormBean.loginName}" size="20" required="true" /> <font color="red">*</font> <h:outputText value="User Name" /> <h:inputText id="userName" value="#{userFormBean.userName}" size="20" required="true" /> <font color="red">*</font> <h:outputText value="User Type" /> <h:selectOneMenu id="userType" value="#{userFormBean.userTypeId}" disabled="true"> <f:selectItems value="#{userFormBean.userTypeList}" /> </h:selectOneMenu> </h:panelGrid> <a4j:commandButton type="submit" value="Submit" action="#{userFormBean.editUser}" style="margin-left:20%;" /> <a4j:region renderRegionOnly="true"> <a4j:commandButton value="Change Password" reRender="errorsMsgPanel" id="changePasswordLink" oncomplete="Richfaces.showModalPanel('changePasswordPanel');" immediate="true"> </a4j:commandButton> </a4j:region> <h:commandButton type="submit" value="Cancel" action="searchUserForm" immediate="true" /> </a4j:region> </rich:panel> </h:panelGrid> </h:form> <a4j:region> <rich:modalPanel id="changePasswordPanel" zindex="2000" autosized="false" height="520" width="520" resizeable="false" moveable="false" shadowDepth="10"> <f:facet name="header"> <rich:spacer height="20px" /> </f:facet> <f:facet name="controls"> <h:panelGroup> <h:graphicImage value="/images/close.png" id="hidelink" styleClass="hidelink" /> <rich:componentControl for="changePasswordPanel" attachTo="hidelink" operation="hide" event="onclick" /> </h:panelGroup> </f:facet> <a4j:region renderRegionOnly="true"> <a4j:include viewId="/ChangePasswordForm.xhtml"></a4j:include> </a4j:region> </rich:modalPanel> </a4j:region> </f:view> </ ui:composition> </ html>
In the above page When ever clicking on "Change Password" ajax command button I need to redirect to Login page if session was expired.
-
9. Re: Sessiontimeout is not working in IE 8
nbelaevski Apr 22, 2010 5:07 PM (in response to veerat)According to your web.xml, session expiration filter is executing before RichFaces filter, but should be executing after
because RichFaces filter provides wrapper for response that actually handles redirects.
-
10. Re: Sessiontimeout is not working in IE 8
veerat Apr 23, 2010 5:37 AM (in response to nbelaevski)Hi Nick,
Thanks you very much It's great answer.My bug was resolved.
In web.xml file, I have changed SessionExpiredFilter configuration like this. Then It started working.
< filter-mapping> <filter-name>SessionExpiredFilter</filter-name> <servlet-name>Faces Servlet</servlet-name> </filter-mapping>