Murphy316
Murphy316

Reputation: 766

Loggin out from Form based authentication

Using servlet 2.3 is there a way to log a user out when he has signed in using form authentication. I know servlet 3.0 has this feature of logging out. What should servlet 2.3 users do for logging out ?

Upvotes: 2

Views: 1542

Answers (2)

Ramesh PVK
Ramesh PVK

Reputation: 15446

Look here Regarding Logout. It also explains the difference between

Servlet 3.0 HttpServletRequest.logout()

and

session.invalidate() method.

Upvotes: 1

BalusC
BalusC

Reputation: 1108712

Just invalidate the session.

request.getSession().invalidate();

Don't forget to send a redirect afterwards.

response.sendRedirect(request.getContextPath() + "/login.jsp");

Upvotes: 3

Related Questions