Internal Server Error in JSP using SpringMVC, SpringSecurity : I'm trying to check if any user is logged in and show Logout button if yes, and Login button otherwise.

**505**

        Type Exception Report
    
    Message An exception occurred processing [/index.jsp] at line [43]
    
    Description The server encountered an unexpected condition that prevented it from fulfilling the request.
    
    Exception
    
    org.apache.jasper.JasperException: An exception occurred processing [/index.jsp] at line [43]
    
    40:                 <a class="btn btn-primary" href="/login" role="button">Login</a>
    41:             </security:authorize>
    42:             <security:authorize access="hasAnyRole('CLIENT', 'ADMIN', 'MANAGER')">
    43:                 <form:form cssClass="form-inline m-0">
    44:                     <h6>Hello, <security:authentication property="principal.username"/></h6>
    45:                     <button class="btn btn-warning" formaction="${pageContext.request.contextPath}/logout" formmethod="post">Logout</button>
    46:                 </form:form>
    
    
    Stacktrace:
    	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:593)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
    	org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
    	org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)


I'm using the following code. It works perfectly on both other pages and not working here. Some kind of magic.


    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
    
    ...
    
     <security:authorize access="!hasAnyRole('CLIENT', 'ADMIN', 'MANAGER')">
                    <a class="btn btn-primary" href="/login" role="button">Login</a>
                </security:authorize>
                <security:authorize access="hasAnyRole('CLIENT', 'ADMIN', 'MANAGER')">
                    <form:form cssClass="form-inline m-0">
                        <h6>Hello, <security:authentication property="principal.username"/></h6>
                        <button class="btn btn-warning" formaction="${pageContext.request.contextPath}/logout" formmethod="post">Logout</button>
                    </form:form>
                </security:authorize>