Directly export to the hello.html page response_demo03.jsp
The code is as follows: |
Copy code |
<% @ Page language = "java" contentType = "text/html" pageEncoding = "GBK" %> <Html> <Head> <Title> Test </title> </Head> <Body> <% Response. sendRedirect ("hello.html "); %> </Body> </Html> |
This jump is a client jump.
<Jsp: forward> is a server jump. The address does not change. You can save the request attribute to the jump page.
Response. sendRedirect () is a client jump, and the address will change. You cannot save the request attribute to the jump page.
Another difference is that the server jump will jump immediately, and the client jump will only jump after the entire page is executed.
Server jump response_demo04.jsp
The code is as follows: |
Copy code |
<% @ Page language = "java" contentType = "text/html" pageEncoding = "GBK" %> <Html> <Head> <Title> Test </title> </Head> <Body> <% System. out. println ("---------- forward jump to the previous -------------"); %> <Jsp: forward page = "hello.html"/> <% System. out. println -------------"); %> </Body> </Html>
|
Display result: hello
However, the background of the tomcat server displays ---------- ----------- before the forward jump -------------
The code is as follows: |
Copy code |
Client jump response_demo05.jsp View sourceprint? <% @ Page language = "java" contentType = "text/html" pageEncoding = "GBK" %> <Html> <Head> <Title> Test </title> </Head> <Body> <% System. out. println ("---------- before the response jump -------------"); %> <% Response. sendRedirect ("hello.html "); %> <% System. out. println ------------"); %> </Body> </Html> The tomcat server background displays ---------- ----------- before the response jump ------------- ------------- |