dhS dhS - 1 year ago 102
Java Question

How can we make a logout page in SpringMVC without using Spring Security?

I am newbie in SpringMVC, trying to make a logout page in an employee details application. An employee can login into his/her details and can change it. But i am confused how to set the logout page.

Please tell me the possible alternatives through which a logout page can make without using spring-security.


Answer Source

You can simply provide a link with url of logout controller method. Suppose you have controller named MiscController with method logout for handling logout, Then code would look like..

public class MiscController {

    public String logout(HttpServletRequest request){
        return "index";

Now in your jsp page you can have a link like..

<a href="${pageContext.servletContext.contextPath}/logout">Logout</a>

On Clicking the logout, You will be logged out and redirected to index.jsp page[Assuming ViewResolver is configured correctly].

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download