- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use <jsp:forward> Action in JSP?
517 Lectures 57 hours
The forward action terminates the action of the current page and forwards the request to another resource such as a static page, another JSP page, or a Java Servlet.
Following is the syntax of the forward action −
<jsp:forward page = "Relative URL" />
Following table lists out the required attributes associated with the forward action −
|Sr.No.||Attribute & Description|
Should consist of a relative URL of another resource such as a static page, another JSP page, or a Java Servlet.
Let us reuse the following two files (a) date.jsp and (b) main.jsp as follows −
Following is the content of the date.jsp file −
<p>Today's date: <%= (new java.util.Date()).toLocaleString()%></p>
Following is the content of the main.jsp file −
<html> <head> <title>The include Action Example</title> </head> <body> <center> <h2>The include action Example</h2> <jsp:forward page = "date.jsp" /> </center> </body> </html>
Let us now keep all these files in the root directory and try to access main.jsp. This would display result something like as below.
Here it discarded the content from the main page and displayed the content from forwarded page only.
Today's date: 12-Sep-2010 14:54:22
- How to use <jsp:useBean> action in JSP?
- How to use <jsp:setProperty> action in JSP?
- How to use <jsp:getProperty> action in JSP?
- How to use <jsp:plugin> Action in JSP?
- What is the use of jsp plugin action element?
- What is the use of jsp text action element?
- What are the different scope values for the JSP action in JSP?
- What is the use of <jsp:text> Action in JSP?
- How to use a filter in JSP?
- How to use resource bundle in JSP?
- How to use time zone in a JSP?
- How to use multiple resource bundle in same JSP?
- How to use parameterized SQL query in a JSP?
- What is the function of <jsp:include> action in JSP?
- How to format number in JSP?