The jsp:forward action tag is used to forward the request to another resource it may be jsp, html or another resource.
<jsp:forward page="relativeURL | <%= expression %>" />
<jsp:forward page="relativeURL | <%= expression %>" > <jsp:param name="parametername" value="parametervalue | <%=expression%>" /> </jsp:forward>
In this example, we are simply forwarding the request to the printdate.jsp file.
<html> <body> <h2>this is index page</h2> <jsp:forward page="printdate.jsp" /> </body> </html>
<html> <body> <% out.print("Today is:"+java.util.Calendar.getInstance().getTime()); %> </body> </html>
In this example, we are forwarding the request to the printdate.jsp file with parameter and printdate.jsp file prints the parameter value with date and time.
<html> <body> <h2>this is index page</h2> <jsp:forward page="printdate.jsp"> <jsp:param name="name" value="silantutorial.com" /> </jsp:forward> </body> </html>
<html> <body> <% out.print("Today is:"+java.util.Calendar.getInstance().getTime()); %> <%= request.getParameter("name") %> </body> </html>
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc