servlet in the forward () and redirect ()

From the address bar is displayed

  • forward is the server resource requests, the server URL to directly access the target address, the response content that URL to read over, and then put these elements and then distributed to the browser

The browser does not know the content sent by the server where it came from, so it's address bar or the original address

  • redirect server is based on logic, send a status code that tells the browser to request the re-address

So the address bar shows the new URL, it is equal to redirect the client request sent twice to the server, but also received two response

From the data sharing for

  • forward () refers to forward, redirect () refers to redirect
  • forward: Forwarding pages and pages can be forwarded to the request which shared data, redirect: can not share data
  • Not only can redirect resources currently redirected to other applications, it can also be redirected to other applications on the same site resources, and even use an absolute URL to redirect to another site resources
  • forward method can only be between resources within the same Web application forwards the request

From efficiency for

forward () high, redirect () Low

Guess you like

Origin www.cnblogs.com/yanguobin/p/11618978.html