stop all polls on session destroy

UI Components for JSF
Post Reply
saraak
Posts: 1
Joined: 12 Jan 2014, 16:34

12 Jan 2014, 16:49

Hi
I have a view bean along with UI page say main.xhtml. there is a poll in main.xhtml which sends request to view bean every 30 seconds. I want all main.xhtml pages stop sending request after session expiration eg. after user logout.
I tried to implement this with a SessionListener class but I wasn't successfull. is there any way to handle this situation either with server side code or client side code?
Thanks

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

13 Jan 2014, 07:57

How to redirect to index page if session time out happend in jsf application

click URL above and read BalusC's answer

my opinion/recommendation... do not leave that page in the browser with stopped polling. if session destroyed, then navigate/redirect the page to a session expired or login page.
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

luxbaumilinovsky
Posts: 4
Joined: 08 Jun 2016, 08:31

06 Sep 2023, 08:04

Late reply, but similar issue!

I have also a poll component on every page which has an intervall of 60 seconds. But with the poll component the HttpSessionListener#sessionDestroyed method will never be called - because there is always an activity! My session timeout is 10 minutes!

So how to distinguish between real activity and activity raised by the poll component?

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

06 Sep 2023, 14:21

The short answer is you can't. Your poller is keeping your session alive and will indefinitely.

That is why we also use an idle poller so if the user is off the tab or stops moving the mouse after N minutes we terminate the poller and log them out of the app.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

luxbaumilinovsky
Posts: 4
Joined: 08 Jun 2016, 08:31

07 Sep 2023, 07:02

@Melloware: Thanks for your hint! I solved it by using an

Code: Select all

<p:idleMonitor>
, which invalidates my session an redirects to the login page.

jepsar
Posts: 166
Joined: 03 Sep 2014, 11:41
Location: NL / BE
Contact:

07 Sep 2023, 21:47

Also, you might want to use a web socket instead.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub: https://github.com/jepsar
Spotify: 90s Rave, Acid, Trance, House

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 92 guests