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 a servlet, JSP, or html file.

 

Syntax:

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

 

Example:

welcome.jsp

<html>
    <head>
        <title>include action example</title>
    </head>
    <body> 
        <h3>Hello this is a include action example.</h3>
        <jsp:include page="home.jsp"/>
    </body>
</html>

 

home.jsp

<html>
    <head>
        <title>include action example</title>
    </head>
    <body>
        <h4>This content is of included file.</h4>
    </body>
</html>

 

web.xml

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