Redirect some users to particular page

Is there any way to achieve what I want to do here in Vaadin? In my system, users are categorized into 2 roles. one is administrator role and the other is regular user role. Administrators can put system into maintenance mode, and regular users can only see a “maintenance” landing page while system in maintenance mode. Administrators can still use system normally.

I can put logic in login page to redirect regular user to “maintenance” landing page. However, this doesn’t work for those users that already login to system because they don’t have go through login page again in order to use system. I am thinking when administrator put system into maintenance mode, I have system expire those regular user sessions. However, there seems no way to get all user sessions. UI.getSession() can only access the session belongs current user.

There is a trick to achieve this in Servlet by using Filter. my question is there anything similar in Vaadin or there is other better way to do what I want to do in Vaadin

PS: I use Vaadin session to store which role current user is. like following code: UI.getCurrent().getSession().setAttribute(“userKeyInSession”, user)

thank you,

Henry

Your use case is pretty much as any chat application or similar: You need some way to send messages between sessions and/or UIs. One way to do it is described in https://vaadin.com/wiki/-/wiki/Main/Broadcasting%20messages%20to%20other%20users. You can of course use JMS or any other messaging system instead, just register all UIs as listener and broadcast a message to them when the system is put in maintenance mode.

Another way would to to add a SessionInitListener in your servlet class so you can get a reference to each VaadinSession and store them somewhere.

If you enable push your users can be immediately redirected somewhere or shown a message when the system goes into maintenance mode. Otherwise they will note it only after the following request.

Thx Artur. I took SessionInitListener approach and it works.