- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 Action in JSP?
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 |
---|---|
1 | page Should consist of a relative URL of another resource such as a static page, another JSP page, or a Java Servlet. |
Example
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
- Related Articles
- How to use action in JSP?
- How to use action in JSP?
- How to use action in JSP?
- How to use Action in JSP?
- What is the use of 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?
- How to use a filter in JSP?
- How to use resource bundle in JSP?
- What is the function of action 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?
- I want to use %> literal in JSP page. But it is throwing error. How to escape this syntax in JSP?

Advertisements