Common practice is to use Filterfor this. Just make it javax.servlet.Filter, define it in web.xml, map it to url-patternfrom, /login.jspand write something like the following in doFilter():
if (((HttpServletRequest) request).getSession().getAttribute("user") != null) {
// User is logged in, redirect to desired page.
((HttpServletResponse) response).sendRedirect("youAreLoggedIn.jsp");
} else {
// Do nothing, continue request.
chain.doFilter(request, response);
}
Simply. He, of course, suggests that the registered Userwas placed in the session area in accordance with normal practices.
However, it <navigation-rule>is specific to JSF, but you did not mention anything about JSF in your question and tags. Aren't you bewildering?
source
share