Basically, I have a login.jsp page and a filter that checks if a session is valid or not. If the session is valid then continue, if not it will redirect to login.jsp.
The filter performs the redirection. However, after being redirected to login.jsp, nothing is shown on webpage. I am sure it’s a problem with the filter, because after removing the filter from web.xml, the login.jsp displays webpage.
The filter is very simple and I got it from here. I don’t know where the problem is in this case. Any suggestions?
if(request.getRequestURI().compareToIgnoreCase("/login.jsp")!=0)
{
if (session != null)
{
if(!session.isNew())
{
chain.doFilter(req, res);
}
}
else
{
System.out.println("Directed");
response.sendRedirect(request.getContextPath() + "/login.jsp");
}
}
else
{
System.out.println("not directed");
}
You need to continue the filter chain for URI’s matching the
login.jspstring. Now all you do is print.Like this:
In the outer else.