[Logo]
Forums Register Login
jsp:forward
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
HttpServletResponse.sendRedirect
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Dec 15, 2017 11:02:37.