Hello! Please help with the code ..
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) resp; String requestURI = request.getRequestURI(); System.out.printf("LoginFilter.doFilter(): requestURI = %s; ", requestURI); String loggedInToken = (String)request.getSession().getAttribute(LoginConstants.LOGIN_FLAG); if (loggedInToken != null) { // User is logged in, continue processing, override getRemoteUser in request object. System.out.printf("user is %s%n", loggedInToken); chain.doFilter(new LoginFilterHTTPServletRequest((HttpServletRequest) req, loggedInToken), resp); return; } ===============================================
The logic of this string is incomprehensible .. After checking "loggedInToken! = Null", the user button will be printed, after which I will be lost .. I will be glad to have some ideas ..
chain.doFilter(new LoginFilterHTTPServletRequest((HttpServletRequest) req, loggedInToken), resp); return;
chain.doFilter()called. If thechainnot called, the request processing will end on this filter. Here is an explanation with pictures, although if you do not know aglitsky at all, then the pictures will not help. docs.oracle.com/cd/B32110_01/web.1013/b28959/filters.htm - Sergeyrequestandresponse, usually passing its wrapper around the receivedrequestandresponseto the next filter. What we see in the example ofLoginFilterHTTPServletRequest. This filter probably wants to implement theloggedInTokenproperty in therequest. In the standard request there is no such property, therefore it replaces it with its wrapper. - Sergey