0

I have intercept the the response using sendRedirect methode. Assume request is coming as test/abc/def so I changed it to test/abc and set into response like below.

`public void doFilter(ServletRequest request, ServletRespose response, FilterChain chain)
{
//request is test/abc/def
String requestPath = ((HttpServletRequest)request).getRequestURI();
requestPath = requestPath.replace("/def","");
httpServletRespose.sendRedirect(requestPath);
chain.doFilter(request,response);

}`

Is this fine ? when URL is test/abc/def I want to send test/abc to next filter. As well as I want to change this request only and don't want to change other requests.

  • Just use an `if/else` statement? Next time to find answers just Google the exception you actually got while doing this. – BalusC Jun 16 '23 at 10:36

0 Answers0