Listening to when the user session is ended in a JSF managed bean2019 Community Moderator ElectionIs there any in JSF2 a callback for activation / deactivation of a session bean?JSF store UserData before Session Invalidate or LogoutJSF Login Two users at the same timeHow to invalidate session in JSF 2.0?JSF Session management and tunningBatching writes to the DB in JSF session scope & writing at the end of user session. Is this approach correct?User Session Management in Restful Web Services in session shared clustered environmentPassing session between jsf backing bean and modelJSF Catch Session TimeoutJSF logout other users while maintaining my active session.Using a HttpServlet Session Attribute in JSFDoes JSF store UIComponents in session?Corruption of a variable in a session bean using JSF/Spring
Is there a place to find the pricing for things not mentioned in the PHB? (non-magical)
Could the Saturn V actually have launched astronauts around Venus?
What's the meaning of a knight fighting a snail in medieval book illustrations?
Custom alignment for GeoMarkers
Do the common programs (for example: "ls", "cat") in Linux and BSD come from the same source code?
As a new Ubuntu desktop 18.04 LTS user, do I need to use ufw for a firewall or is iptables sufficient?
Is it true that good novels will automatically sell themselves on Amazon (and so on) and there is no need for one to waste time promoting?
How to make healing in an exploration game interesting
While on vacation my taxi took a longer route, possibly to scam me out of money. How can I deal with this?
When to use a slotted vs. solid turner?
Math equation in non italic font
What is the adequate fee for a reveal operation?
Why do newer 737s use two different styles of split winglets?
Why is the President allowed to veto a cancellation of emergency powers?
Adventure Game (text based) in C++
Print a physical multiplication table
Do I need to be arrogant to get ahead?
What options are left, if Britain cannot decide?
Most cost effective thermostat setting: consistent temperature vs. lowest temperature possible
Does .bashrc contain syntax errors?
I got the following comment from a reputed math journal. What does it mean?
Knife as defense against stray dogs
If I can solve Sudoku, can I solve the Travelling Salesman Problem (TSP)? If so, how?
Why do tuner card drivers fail to build after kernel update to 4.4.0-143-generic?
Listening to when the user session is ended in a JSF managed bean
2019 Community Moderator ElectionIs there any in JSF2 a callback for activation / deactivation of a session bean?JSF store UserData before Session Invalidate or LogoutJSF Login Two users at the same timeHow to invalidate session in JSF 2.0?JSF Session management and tunningBatching writes to the DB in JSF session scope & writing at the end of user session. Is this approach correct?User Session Management in Restful Web Services in session shared clustered environmentPassing session between jsf backing bean and modelJSF Catch Session TimeoutJSF logout other users while maintaining my active session.Using a HttpServlet Session Attribute in JSFDoes JSF store UIComponents in session?Corruption of a variable in a session bean using JSF/Spring
Is it possible to do something like this: When a user session starts I read a certain integral attribute from the database. As the user performs certain activities in this session, I update that variable(stored in session) & when the session ends, then I finally store that value to the DB.
My question is how do I identify using the JSF framework if the user session has ended & I should then store the value back to DB?
session jsf listener managed-bean
add a comment |
Is it possible to do something like this: When a user session starts I read a certain integral attribute from the database. As the user performs certain activities in this session, I update that variable(stored in session) & when the session ends, then I finally store that value to the DB.
My question is how do I identify using the JSF framework if the user session has ended & I should then store the value back to DB?
session jsf listener managed-bean
add a comment |
Is it possible to do something like this: When a user session starts I read a certain integral attribute from the database. As the user performs certain activities in this session, I update that variable(stored in session) & when the session ends, then I finally store that value to the DB.
My question is how do I identify using the JSF framework if the user session has ended & I should then store the value back to DB?
session jsf listener managed-bean
Is it possible to do something like this: When a user session starts I read a certain integral attribute from the database. As the user performs certain activities in this session, I update that variable(stored in session) & when the session ends, then I finally store that value to the DB.
My question is how do I identify using the JSF framework if the user session has ended & I should then store the value back to DB?
session jsf listener managed-bean
session jsf listener managed-bean
edited Mar 19 '16 at 13:50
BalusC
855k30031673233
855k30031673233
asked Jun 5 '11 at 5:50
Rajat GuptaRajat Gupta
10.8k48149266
10.8k48149266
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Apart from the HttpSessionListener
, you can use a session scoped managed bean for this. You use @PostConstruct
(or just the bean's constructor) and @PreDestroy
annotations to hook on session creation and destroy
@ManagedBean
@SessionScoped
public class SessionManager
@PostConstruct
public void sessionInitialized()
// ...
@PreDestroy
public void sessionDestroyed()
// ...
The only requirement is that this bean is referenced in a JSF page or as @ManagedProperty
of any request scoped bean. Otherwise it won't get created. But in your case this should be no problem as you're apparently already using a session scoped managed bean, just adding a @PreDestroy
method ought to be sufficient.
I am trying this second approach as it looks good. Plus I need to be able to get a handle on ejbs and entity manager which seems to only be available from managed beans in JSF (as opposed to the HttpSessionListener). I make the sessionscoped managedbean a managedproperty of my login handling requestscoped bean so that it comes into scope when the user logs in. The problem I'm having is that it seems the method I marked @PreDestroy gets called as the login bean goes out of scope (i.e. when the login method returns). So my code is firing early. Any ideas on why this might happen?
– Bill Rosmus
Aug 7 '12 at 2:05
mkyong.com/servlet/…
– Mahdi Esmaeili
Dec 12 '18 at 11:39
add a comment |
My question is how do I identify using
the JSF framework if the user session
has ended & I should then store the
value back to DB?
The JSF framework does not have a separate concept of a session; it uses the underlying session management features of the Servlet specification.
You would have to create a HttpSessionListener that provides hooks for you to capture the session creation and destruction events, where you can read the value and store it back into the DB.
add a comment |
HttpSessionListener
, or if you need Dependency Injection for that save, you might use @PostConstruct & @PreDestroy
. Remember that the session is destroyed when you call invalidate()
or after session timeout, not when the user closes the browser. Why do you use Session Scope anyway, Conversation Scope might fit you better.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f6241249%2flistening-to-when-the-user-session-is-ended-in-a-jsf-managed-bean%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Apart from the HttpSessionListener
, you can use a session scoped managed bean for this. You use @PostConstruct
(or just the bean's constructor) and @PreDestroy
annotations to hook on session creation and destroy
@ManagedBean
@SessionScoped
public class SessionManager
@PostConstruct
public void sessionInitialized()
// ...
@PreDestroy
public void sessionDestroyed()
// ...
The only requirement is that this bean is referenced in a JSF page or as @ManagedProperty
of any request scoped bean. Otherwise it won't get created. But in your case this should be no problem as you're apparently already using a session scoped managed bean, just adding a @PreDestroy
method ought to be sufficient.
I am trying this second approach as it looks good. Plus I need to be able to get a handle on ejbs and entity manager which seems to only be available from managed beans in JSF (as opposed to the HttpSessionListener). I make the sessionscoped managedbean a managedproperty of my login handling requestscoped bean so that it comes into scope when the user logs in. The problem I'm having is that it seems the method I marked @PreDestroy gets called as the login bean goes out of scope (i.e. when the login method returns). So my code is firing early. Any ideas on why this might happen?
– Bill Rosmus
Aug 7 '12 at 2:05
mkyong.com/servlet/…
– Mahdi Esmaeili
Dec 12 '18 at 11:39
add a comment |
Apart from the HttpSessionListener
, you can use a session scoped managed bean for this. You use @PostConstruct
(or just the bean's constructor) and @PreDestroy
annotations to hook on session creation and destroy
@ManagedBean
@SessionScoped
public class SessionManager
@PostConstruct
public void sessionInitialized()
// ...
@PreDestroy
public void sessionDestroyed()
// ...
The only requirement is that this bean is referenced in a JSF page or as @ManagedProperty
of any request scoped bean. Otherwise it won't get created. But in your case this should be no problem as you're apparently already using a session scoped managed bean, just adding a @PreDestroy
method ought to be sufficient.
I am trying this second approach as it looks good. Plus I need to be able to get a handle on ejbs and entity manager which seems to only be available from managed beans in JSF (as opposed to the HttpSessionListener). I make the sessionscoped managedbean a managedproperty of my login handling requestscoped bean so that it comes into scope when the user logs in. The problem I'm having is that it seems the method I marked @PreDestroy gets called as the login bean goes out of scope (i.e. when the login method returns). So my code is firing early. Any ideas on why this might happen?
– Bill Rosmus
Aug 7 '12 at 2:05
mkyong.com/servlet/…
– Mahdi Esmaeili
Dec 12 '18 at 11:39
add a comment |
Apart from the HttpSessionListener
, you can use a session scoped managed bean for this. You use @PostConstruct
(or just the bean's constructor) and @PreDestroy
annotations to hook on session creation and destroy
@ManagedBean
@SessionScoped
public class SessionManager
@PostConstruct
public void sessionInitialized()
// ...
@PreDestroy
public void sessionDestroyed()
// ...
The only requirement is that this bean is referenced in a JSF page or as @ManagedProperty
of any request scoped bean. Otherwise it won't get created. But in your case this should be no problem as you're apparently already using a session scoped managed bean, just adding a @PreDestroy
method ought to be sufficient.
Apart from the HttpSessionListener
, you can use a session scoped managed bean for this. You use @PostConstruct
(or just the bean's constructor) and @PreDestroy
annotations to hook on session creation and destroy
@ManagedBean
@SessionScoped
public class SessionManager
@PostConstruct
public void sessionInitialized()
// ...
@PreDestroy
public void sessionDestroyed()
// ...
The only requirement is that this bean is referenced in a JSF page or as @ManagedProperty
of any request scoped bean. Otherwise it won't get created. But in your case this should be no problem as you're apparently already using a session scoped managed bean, just adding a @PreDestroy
method ought to be sufficient.
edited Jun 5 '11 at 11:34
answered Jun 5 '11 at 11:14
BalusCBalusC
855k30031673233
855k30031673233
I am trying this second approach as it looks good. Plus I need to be able to get a handle on ejbs and entity manager which seems to only be available from managed beans in JSF (as opposed to the HttpSessionListener). I make the sessionscoped managedbean a managedproperty of my login handling requestscoped bean so that it comes into scope when the user logs in. The problem I'm having is that it seems the method I marked @PreDestroy gets called as the login bean goes out of scope (i.e. when the login method returns). So my code is firing early. Any ideas on why this might happen?
– Bill Rosmus
Aug 7 '12 at 2:05
mkyong.com/servlet/…
– Mahdi Esmaeili
Dec 12 '18 at 11:39
add a comment |
I am trying this second approach as it looks good. Plus I need to be able to get a handle on ejbs and entity manager which seems to only be available from managed beans in JSF (as opposed to the HttpSessionListener). I make the sessionscoped managedbean a managedproperty of my login handling requestscoped bean so that it comes into scope when the user logs in. The problem I'm having is that it seems the method I marked @PreDestroy gets called as the login bean goes out of scope (i.e. when the login method returns). So my code is firing early. Any ideas on why this might happen?
– Bill Rosmus
Aug 7 '12 at 2:05
mkyong.com/servlet/…
– Mahdi Esmaeili
Dec 12 '18 at 11:39
I am trying this second approach as it looks good. Plus I need to be able to get a handle on ejbs and entity manager which seems to only be available from managed beans in JSF (as opposed to the HttpSessionListener). I make the sessionscoped managedbean a managedproperty of my login handling requestscoped bean so that it comes into scope when the user logs in. The problem I'm having is that it seems the method I marked @PreDestroy gets called as the login bean goes out of scope (i.e. when the login method returns). So my code is firing early. Any ideas on why this might happen?
– Bill Rosmus
Aug 7 '12 at 2:05
I am trying this second approach as it looks good. Plus I need to be able to get a handle on ejbs and entity manager which seems to only be available from managed beans in JSF (as opposed to the HttpSessionListener). I make the sessionscoped managedbean a managedproperty of my login handling requestscoped bean so that it comes into scope when the user logs in. The problem I'm having is that it seems the method I marked @PreDestroy gets called as the login bean goes out of scope (i.e. when the login method returns). So my code is firing early. Any ideas on why this might happen?
– Bill Rosmus
Aug 7 '12 at 2:05
mkyong.com/servlet/…
– Mahdi Esmaeili
Dec 12 '18 at 11:39
mkyong.com/servlet/…
– Mahdi Esmaeili
Dec 12 '18 at 11:39
add a comment |
My question is how do I identify using
the JSF framework if the user session
has ended & I should then store the
value back to DB?
The JSF framework does not have a separate concept of a session; it uses the underlying session management features of the Servlet specification.
You would have to create a HttpSessionListener that provides hooks for you to capture the session creation and destruction events, where you can read the value and store it back into the DB.
add a comment |
My question is how do I identify using
the JSF framework if the user session
has ended & I should then store the
value back to DB?
The JSF framework does not have a separate concept of a session; it uses the underlying session management features of the Servlet specification.
You would have to create a HttpSessionListener that provides hooks for you to capture the session creation and destruction events, where you can read the value and store it back into the DB.
add a comment |
My question is how do I identify using
the JSF framework if the user session
has ended & I should then store the
value back to DB?
The JSF framework does not have a separate concept of a session; it uses the underlying session management features of the Servlet specification.
You would have to create a HttpSessionListener that provides hooks for you to capture the session creation and destruction events, where you can read the value and store it back into the DB.
My question is how do I identify using
the JSF framework if the user session
has ended & I should then store the
value back to DB?
The JSF framework does not have a separate concept of a session; it uses the underlying session management features of the Servlet specification.
You would have to create a HttpSessionListener that provides hooks for you to capture the session creation and destruction events, where you can read the value and store it back into the DB.
answered Jun 5 '11 at 6:18
Vineet ReynoldsVineet Reynolds
66.3k16131169
66.3k16131169
add a comment |
add a comment |
HttpSessionListener
, or if you need Dependency Injection for that save, you might use @PostConstruct & @PreDestroy
. Remember that the session is destroyed when you call invalidate()
or after session timeout, not when the user closes the browser. Why do you use Session Scope anyway, Conversation Scope might fit you better.
add a comment |
HttpSessionListener
, or if you need Dependency Injection for that save, you might use @PostConstruct & @PreDestroy
. Remember that the session is destroyed when you call invalidate()
or after session timeout, not when the user closes the browser. Why do you use Session Scope anyway, Conversation Scope might fit you better.
add a comment |
HttpSessionListener
, or if you need Dependency Injection for that save, you might use @PostConstruct & @PreDestroy
. Remember that the session is destroyed when you call invalidate()
or after session timeout, not when the user closes the browser. Why do you use Session Scope anyway, Conversation Scope might fit you better.
HttpSessionListener
, or if you need Dependency Injection for that save, you might use @PostConstruct & @PreDestroy
. Remember that the session is destroyed when you call invalidate()
or after session timeout, not when the user closes the browser. Why do you use Session Scope anyway, Conversation Scope might fit you better.
answered Jun 5 '11 at 12:33
Cosmin CosminCosmin Cosmin
1,05911333
1,05911333
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f6241249%2flistening-to-when-the-user-session-is-ended-in-a-jsf-managed-bean%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown