Yes it is possible.
But I would suggest you apply a filter to /login.jsp and go to another page in the filter if the user has already logged in.
Here is an example that tells how to do this using a filter:
public class LoginPageFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; if(request.getUserPrincipal() != null){
Add this filter to the web.xml file
<filter> <filter-name>LoginPageFilter</filter-name> <filter-class> com.sample.LoginPageFilter </filter-class> <init-param> <param-name>test-param</param-name> <param-value>This parameter is for testing.</param-value> </init-param> </filter> <filter-mapping> <filter-name>LoginPageFilter</filter-name> <url-pattern>/login.jsp</url-pattern> </filter-mapping>
source share