Answer the question
In order to leave comments, you need to log in
How to change query parameter in Filter?
Hello. I have a task in the filter to change the request sent to the servlet. Please advise how this can be done.
public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
throws java.io.IOException, ServletException {
request.setAttribute("param", "Hello");
HttpServletRequest req = (HttpServletRequest) request;
System.out.println(req.getParameter("param"));
RequestDispatcher dispatcher = request.getRequestDispatcher("/");
dispatcher.forward(request, response);
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