amandina
amandina

Reputation: 51

context destroyed, but ths session is still open

I'm new to jsf and I've read that a session can be destroyed

FacesContext fc = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) fc.getExternalContext().getSession(false);      

fc.getExternalContext().getSessionMap().clear();

session.invalidate();

My problem ist, after doing that the session is still active, with the following bean :

com.sun.faces.renderkit.ServerSideStateHelper.LogicalViewMap

Do you have an idea?

Upvotes: 0

Views: 892

Answers (1)

BalusC
BalusC

Reputation: 1108982

That's just a new session. To test it yourself, check the value of HttpSession#getId() during the request before and after invalidate. It should be different.


Unrelated to the concrete question, clearing the session map is unnecessary whenever you call invalidate(). The session map will be trashed anyway. Also note that getSession(false) can potentially return null and you'd like to add an extra check to avoid NullPointerException. Or just use getSession(true) instead.

Upvotes: 2

Related Questions