0

I am having a filter at a location (/dir/store_image/*).

When I am redirecting to it through a RequestDispatcher its not working.

But its working fine with response.sendRedirect.

With requestDispatcher the output is - the requested resource is not available.

The example code -

String path = req.getRequestURI() ;

path = path.substring(path.lastIndexOf("/")+1, path.length());

path = "../dir/store_image/" + path;

/* Not working
  RequestDispatcher request_Dispatcher=request.getRequestDispatcher(path);
  request_Dispatcher.forward(request,response);*/

//Working

HttpServletResponse httpResponse = (HttpServletResponse) response;
httpResponse.sendRedirect(path);

The filter mapping -

(from StoreImageA i am forwarding to StoreImage)

<filter-mapping>
    <filter-name>StoreImage</filter-name>
    <url-pattern>/dir/store_image/*</url-pattern>
</filter-mapping>


<filter-mapping>
    <filter-name>StoreImageA</filter-name>
    <url-pattern>/store_image/*</url-pattern>
</filter-mapping>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Pradyut Bhattacharya
  • 5,440
  • 13
  • 53
  • 83

0 Answers0