我正在尝试将我的请求从过滤器重定向到另一台服务器,以下代码段是从过滤器重定向的一部分
Filter.java
try {
String redirectUrl = “https://abc.xyz.com/home”;
response.sendRedirect(redirectUrl);
return;
} catch (Exception ex) {
logger.log(Level.INFO, "====== thus the occured exception is ====== "+ex);
}
Servlet.java
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
LOGGER.log(Level.INFO, "------ entering into download servlet !");
res.getWriter().write("Processed download request");
LOGGER.log(Level.INFO, "------ completed processing the servlet !");
return;
}
预期:请求将从过滤器重定向,不会进入servlet
但是发生了什么:
请问是否有任何方式从过滤器本身重定向而不进入servlet? tomcat如何将请求从过滤器转发到servlet?