Definition and practical meaning of @SessionScoped
I would like to understand the full meaning of the @SessionScoped
annotation in a JSF ManagedBean.
I guess it is related to the http session, but still, it's not very clear to m开发者_StackOverflow社区e when it starts, when it ends and if it can be interrupted.
- If I leave a browser open, without activity, during 2 hours. Is the session still open?
- Is a session shared across browser tabs
- Does a session behave identical in say Firefox, IE or Safari?
- ...
- no, the session times-out if there is no activity
- yes, the session is shared across browser tabs
- yes, the session is a server-side notion mainly, browsers only send a cookie to identify
The session starts when the user requests the first page.
The @PostConstruct
method of session scoped beans (if exists) is invoked when you first access a page that references that bean (I'm not entirely sure in this, though)
The session ends when you call session.invalidate()
or when it times-out (the timeout period if configurable in web.xml
). Then the @PreDestroy
method (if exists) is invoked.
精彩评论