Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your filter is redirecting to an URL which is invoking the very same filter with the very same conditions again which in turn thus results in a new redirect, etcetera. Your filter is basically redirecting to itself in an infinite loop. The webbrowser is blocking the infinite loop after ~20 requests to save the enduser from badly designed webapplications.</p> <p>You need to fix your filter accordingly that it is not performing a redirect when it has already been performed. Let's assume a basic real world example of a login filter which is mapped on <code>/*</code> which should be redirecting to the login page when the user is not logged in which is identified by <code>user</code> attribute in session. You obviously want that the filter should not redirect to the login page if the login page itself is currently been requested.</p> <pre><code>@WebFilter("/*") public class LoginFilter implements Filter { @Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; HttpSession session = request.getSession(false); String loginURL = request.getContextPath() + "/login.jsp"; boolean loggedIn = session != null &amp;&amp; session.getAttribute("user") != null; boolean loginRequest = request.getRequestURI().equals(loginURL); if (loggedIn || loginRequest) { chain.doFilter(request, response); // Logged-in user found or already in login page, so just continue request. } else { response.sendRedirect(loginURL); // No logged-in user found and not already in login page, so redirect to login page. } } // ... } </code></pre> <p>You see, if you want to allow/continue a request, just call <code>chain.doFilter()</code> instead of <code>response.sendRedirect()</code>. Use redirect only if you want to change a request to a different destination.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload