Test. jsp page
1. system. Out. println ("before response. sendredirect ");
2. response. sendredirect ("/target. jsp ");
3. system. Out. println ("After response. sendredirect ");
Why is the execution performed in line 3?
I thought that sendredirect was executed, and the request was redirected. The code below should not be executed, but now we want to continue the execution. Please explain it clearly. Thank you.
// ================================================ ========================================================== ==================================
Where is return the end of a method?
As long as return is not added, all the code after sendredirect will be executed? When will the page Jump?
As you said, how can such code go?
Response. sendredirect ("/a. jsp ");
Response. sendredirect ("/B. jsp ");
Response. sendredirect ("/C. jsp ");
Response. sendredirect ("/D. jsp ");
// ================================================ ========================================================== ==================================
I agree that csdn_pistachio and sendredirect () are nothing more than a common method call,
I personally think response. sendredirect ("/a. jsp ");
Response. sendredirect ("/B. jsp ");
Response. sendredirect ("/C. jsp ");
Response. sendredirect ("/d. JSP "); finally to D. JSP only allows the client browser to send three redirection commands. does not affect the server. therefore, you can perform database storage and processing later.
// ================================================ ========================================================== ==================================
Back to WTS (Tiansheng) & xchn (xchn)
Although no output can be made to reponse after sendredirect () is called (including re-sendredirect, so the upstairs statement is also wrong ), however, the browser has not actually received this command. The redirection command is sent to the client only after the code after sendredirect is executed, and then the client browser requests a new URL. This is the execution process of redirection.
// ================================================ ========================================================== ==================================
"I thought sendredirect was executed, and the request was redirected. The code below should not be executed. But now we want to continue executing the code. Please explain it clearly. Thank you ."
Do not use the behavioral characteristics of traditional Java applications to view the behavioral characteristics of Web applications in B/S.
In fact, the verification is very simple. add a loop delay before the out, and check whether the redirection page comes out first or the console's "After response. sendredirect "can be determined now.
Add code:
Response. sendredirect ("date. jsp ");
Response. flushbuffer (); // It can prove that even if it has been submitted, it has not been sent to the client immediately
For (INT I = 0; I <9999; I ++) // The numeric size depends on the performance of your machine.
For (Int J = 0; j <99999; j ++ );
System. Out. println ("after redirect ");