Java MCQ: Which tag is used in JSP to forward a request to another resource?
a) <jsp:forward>
b) <jsp:include>
c) <jsp:param>
d) <jsp:redirect>
Answer:
a) <jsp:forward>
Explanation:
The <jsp:forward>
tag is used in JSP to forward a request to another resource, such as another JSP page, Servlet, or HTML page. This tag allows the current request to be transferred to a different resource, and the original response is not sent to the client.
Here’s an example of using <jsp:forward>
:
<jsp:forward page="anotherPage.jsp" />
In this example, the request is forwarded to anotherPage.jsp
, and the response from that page is sent to the client instead of the original JSP page.
The <jsp:forward>
tag is useful for creating modular and reusable components in web applications, allowing one resource to delegate the processing of a request to another.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html