jsp:forward action tag

jsp:forward action tag is used for controlling the page flow. It forwards the request from a JSP to the other resource. Another resource can be servlet, jsp or html file.

Syntax: <jsp:forward page=”URL of other resource”/>

Example:

welcome.jsp

<html>
	<head>
		<title>forward action example</title>
	</head>
	<body> 
		<jsp:forward page="home.jsp"/>
	</body>
</html>

home.jsp

<html>
	<head>
		<title>forward action example</title>
	</head>
	<body>
		<h4>This content is of that resource 
                                on which request is forwarded.</h4>
	</body>
</html>

web.xml

<web-app>
 
  <welcome-file-list>
          <welcome-file>welcome.jsp</welcome-file>
  </welcome-file-list>	
 
</web-app>

Output:

jsp example 28
 
Download this example.
 
Next Topic: jsp:include action tag with example.
Previous Topic: JSP action tags with example.

Related Topics:

JSP action tags with example.
jsp:forward action tag with example.
jsp:include action tag with example.
jsp:param action tag with example.
jsp:useBean, jsp:setProperty and jsp:getProperty action tag.
Exception handling in JSP with example.
JSP Expression Language with example.