Answer the question
In order to leave comments, you need to log in
How to correctly pass reCAPTCHA through the FilterChain filter?
Greetings dear forum users.
I have such a task. I pass the reCAPTCHA
validation mechanism through the FilterChain filter and if false occurs , then it redirects back to the same “/login†page . Here's how I can properly tell the “/login†controller that the client failed the CAPTCHA check ?
package com.test;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.GenericFilterBean;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Component
public class Test extends GenericFilterBean {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + "/login");
chain.doFilter(request, response);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question