Article Directory
1. Request forwarding
Request forwarding is an 服务器内部
existing resource jump method
step:
request
Get request forwarder object through object:RequestDispatcher getRequestDispatcher(String path);
- Use
RequestDispatcher
objects to forward:forward(ServletRequest request,ServletResponse response);
Generally use chain programming to write directly into one line:
request.getRequestDispatcher(String path).forward(request,response);
Features:
- Request forwarding browser address bar path does not change
- Can only be forwarded to the internal resources of the current server
- Forwarding is a request
2. Sharing resources
Domain object: an object with a scope that can share data within the scope
request
Domain: Represents the scope of a request, and is generally used to share data among multiple resources requested for forwarding
method:
void setAttribute(String name,Object obj)
:Storing dataObject getAttribute(String name)
: Get value by keyvoid romoveAttribute(String name)
: Remove key-value pairs by key