Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

JSF%20Interview%20Questions%20and%20Answers

Question: How to terminate the session?
Answer: In order to terminate the session you can use session invalidate method.

This is an example how to terminate the session from the action method of a backing bean:

public String logout() {
FacesContext fc = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) fc.getExternalContext().getSession(false);
session.invalidate();
return "login_page";
}
The following code snippet allows to terminate the session from the jsp page:

<% session.invalidate(); %>
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook