When I make filter for all jsp pages, the browser goes into an infinite loop, but when I make filter for only one page, it runs correctly!!
Here is doFilter method, if some one find the error plx tell me...
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
if (debug) log("AuthenticationFilter:doFilter()");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
HttpServletResponse httpres = (HttpServletResponse) response;
HttpServletRequest httpreq = (HttpServletRequest) request;
if (httpreq.getRequestURI().indexOf("login.jsp") == -1 || httpreq.getRequestURI().indexOf("LoginServlet") == -1) {
// if(!httpreq.getRequestURL().equals("/OSQS/Login.jsp")){
HttpSession session = httpreq.getSession();
String logged = (String) session.getAttribute("login");
if (logged == null) {
httpres.sendRedirect("login.jsp");
return;
}
}
chain.doFilter(request, response);
}