Forums Register Login
Can somebody explain why file1 will be displayed instead of jsp2

If the code below is executed in file1.jsp what will the location bar of the browser display after the execution.
<jsp:forward page="file2.jsp" />
You answered: A

A file1.jsp
B file2.jsp
C file1.jsp_file2.jsp
D Code will not compile
file1.jsp is displayed. A is true. B would be true when using response.sendRedirect
What is displayed in a browsers Address or Location Bar is the URL requested from the server. Using jsp:forward, the clients single request is past along to the second resource without telling the browser so, the initial url is displayed. On response.sendRedirect, the clients initial rquest is anwsered with the http header set with the Redirect Response code causing the browser to make a new request for the second URL.
So,RequestDispatcher.forward() is transparent to the browser, unlike

This thread has been viewed 507 times.

All times above are in ranch (not your local) time.
The current ranch time is
Oct 20, 2018 07:56:26.