request.getRequestDispatcherd的数据流图
1.sendRedirect()重定向,转发 forward()转向
2.发生在:
sendRedirect 在浏览器
forward 在web服务器
3.用法:
request.getRequestDispatcher(”/资源“).forward(request,response)
request.sendRedirect(“/web应用/资源”);
4.可以用得URL不同
sendRedirect()可以去任何url
forward 只能去当前web应用
多个servlet可以用forward连起来
浏览器显示的是第一个forward的servlet