Partial AJAX calls don't handle container session timeouts
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Problem with phaselistener is that it gets executed on every single request, exception handler is executed when something goes wrong which is ideal. Still it is a good trick for JSF 1.2 users.
Its, still a good trick for JSF2.1 users, but I recognize the benefit of exception listener;)optimus.prime wrote:Problem with phaselistener is that it gets executed on every single request, exception handler is executed when something goes wrong which is ideal. Still it is a good trick for JSF 1.2 users.
EDIT: Maybe especially for users paranoid about security who want to check at every single RequestCycle whether the World is still ok
Busy applying primefaces patches to my local repo at /dev/null
-
- Posts: 6144
- Joined: 10 Sep 2011, 21:10
Thank you ALL! I appreciate this topic and your responses. Bookmarking this topic for later reference.
Howard
PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome
Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache
PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome
Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache
Dealing Gracefully with ViewExpiredException
http://weblogs.java.net/blog/edburns/ar ... ption-jsf2
http://weblogs.java.net/blog/edburns/ar ... ption-jsf2
7ec Solutions http://www.7ec.com.br/
Mojarra 2.1.6
PrimeFaces 4.0
PrimeFaces Extensions 1.1.0
GlassFish Server 3.1.2
Mojarra 2.1.6
PrimeFaces 4.0
PrimeFaces Extensions 1.1.0
GlassFish Server 3.1.2
Hello Cagatay,
Have you tried your solution for DataTable pagination / sorting? Do you see the "Ooops" dialog when you click on any DataTable's page in the expired web app? In PF 2.2.1 we had (have) a lot of use cases where ExceptionHandler doesn't catch ViewExpiredException.
I would also invalidate session when ViewExpiredException occurs (session.invalidate()) because ViewExpiredException doesn't mean that session got invalidated. There are scenarios beyond session expriration which cause the same exception. Especially working in several browser tabs with the same web app.
Have you tried your solution for DataTable pagination / sorting? Do you see the "Ooops" dialog when you click on any DataTable's page in the expired web app? In PF 2.2.1 we had (have) a lot of use cases where ExceptionHandler doesn't catch ViewExpiredException.
I would also invalidate session when ViewExpiredException occurs (session.invalidate()) because ViewExpiredException doesn't mean that session got invalidated. There are scenarios beyond session expriration which cause the same exception. Especially working in several browser tabs with the same web app.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin
What if the webapp is protected by a filter like http://www.jasig.org/cas
The session is gone then the filter will redirect to a login page. The exception-handler-factory can never actually be called.
CAS works well for non-ajax requests but fails when using a ajax page.
What changes would need to occur on the CAS filter such that primefaces sees the redirect when using ajax ?
Or is something else needed in primefaces to catch the redirect ?
The session is gone then the filter will redirect to a login page. The exception-handler-factory can never actually be called.
CAS works well for non-ajax requests but fails when using a ajax page.
What changes would need to occur on the CAS filter such that primefaces sees the redirect when using ajax ?
Or is something else needed in primefaces to catch the redirect ?
prime faces 7.0.11
jsf 2.3.9
tomcat 9.0.50
jsf 2.3.9
tomcat 9.0.50
I have boiled ajax error catching down to 2 scenarios:
1. How to deal with an AJAX page when tomcat is down:
2. How to deal when session is expired:
I tried
but it does not seem to work.
I tried it with 3.1.1 and 2.0.9 JSF
1. How to deal with an AJAX page when tomcat is down:
Code: Select all
Status Code 503
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>503 Service Temporarily Unavailable</title>
</head><body>
<h1>Service Temporarily Unavailable</h1>
<p>The server is temporarily unable to service your
request due to maintenance downtime or capacity
problems. Please try again later.</p>
<hr>
<address>Apache/2.2.20 (Ubuntu) Server Port 80</address>
</body></html>
Code: Select all
Status Code 302
Location=https://server.com/cas/login?TARGET=http%3A%2F%2Fserver.com%2Fwar%2Fjob%2FlistTask.jsf
Code: Select all
<p:confirmDialog id="timeout" header="Oooops!!!" severity="alert" visible="#{not empty param['TARGET']}" message="View has expired." widgetVar="confirmDlg">
<p:commandButton type="button" value="Whatever" onclick="confirmDlg.hide()" />
</p:confirmDialog>
I tried it with 3.1.1 and 2.0.9 JSF
prime faces 7.0.11
jsf 2.3.9
tomcat 9.0.50
jsf 2.3.9
tomcat 9.0.50
-
- Posts: 6144
- Joined: 10 Sep 2011, 21:10
I'm trying to use Filter too, which checks a UserManager/LoginBean, and it redirects to Login page if LoginBean == null or userIsLoggedIn() == false. I recognize the same behavior, and exception handler factory not called. I haven't finished trying out different approaches.mores wrote:What if the webapp is protected by a filter like http://www.jasig.org/cas
The session is gone then the filter will redirect to a login page. The exception-handler-factory can never actually be called.
CAS works well for non-ajax requests but fails when using a ajax page.
What changes would need to occur on the CAS filter such that primefaces sees the redirect when using ajax ?
Or is something else needed in primefaces to catch the redirect ?
In this post, Best way to implement user login page in JSF, BalusC recommends filter over a phaseListener. So, this is the reason why I went with a filter, but I wonder if phaseListener is better for AJAX and non-AJAX.
Howard
PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome
Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache
PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome
Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache
I feel like I am getting close. I am looking for a simple client side error routine.
In a plain jsf/ajax page without primefaces I can do this:
If I add that same code to a primefaces page, then I click on a primefaces component I never see the alert.
Is primefaces catching that error ? If so can it either propagate it up so I can catch it or present a similar alert that can have a custom message ?
Icefaces has a client side error handler:
http://wiki.icefaces.org/display/ICE/Ha ... Exceptions
In a plain jsf/ajax page without primefaces I can do this:
Code: Select all
<h:outputScript name="jsf.js" library="javax.faces" target="head"/>
<script type="text/javascript">
jsf.ajax.addOnError(function() {alert("Please refresh your browser.");});
</script>
Is primefaces catching that error ? If so can it either propagate it up so I can catch it or present a similar alert that can have a custom message ?
Icefaces has a client side error handler:
Code: Select all
var iceErrorCallback = function iceHandleError(statusCode, responseTxt, responseDOM) {
//Handle all errors by simply redirecting to an error page
window.location.href = "./generalError.xhtml";
}
prime faces 7.0.11
jsf 2.3.9
tomcat 9.0.50
jsf 2.3.9
tomcat 9.0.50
-
- Posts: 6144
- Joined: 10 Sep 2011, 21:10
I added the following to <head>...</head>
Got it from URL below (another great BalusC 'answer'/solution):
http://stackoverflow.com/questions/4992 ... in-jsf-2-0
I also have loginFilter in place, but the code above is really no good for AJAX/PPR, since entire page does not refresh, and page refreshes when timer runs down. Maybe I should add some type of session == null && session.maxInactiveInterval. Actually, I'm thinking of adding more non-AJAX requests to force full-page refresh... only for the menuitems in the main/page menubar.
Code: Select all
<meta http-equiv="refresh" content="#{session.maxInactiveInterval};url=login.jsf" />
http://stackoverflow.com/questions/4992 ... in-jsf-2-0
I also have loginFilter in place, but the code above is really no good for AJAX/PPR, since entire page does not refresh, and page refreshes when timer runs down. Maybe I should add some type of session == null && session.maxInactiveInterval. Actually, I'm thinking of adding more non-AJAX requests to force full-page refresh... only for the menuitems in the main/page menubar.
Howard
PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome
Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache
PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome
Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache
-
- Information
-
Who is online
Users browsing this forum: No registered users and 8 guests