JSP Forward Example

JSP Forward Example explains step by step details of dynamically forward a jsp page

Consider an example where we are forwarding to (welcome.jsp) from forward.jsp.

When you call jsp:forward tag, the request is forward to another resource (jsp page or servlet) on the server, without the client's (Browser) knowledge. ie; url is not changed even forwarding to another page (Here it is from forward.jsp to welcome.jsp)

This happens completely inside the web container

You can see the below example, which is demonstrating JSP Forward Example

Note

You can also find following related tutorials on this blog

1) JSP Include Example 2) JSP Redirect Example

forward.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>jsp:forward example</title>
</head>
<body>
    This is a page<br/>
    <jsp:forward page="welcome.jsp" />
</body>
</html>

welcome.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome</title>
</head>
<body>
    Welcome Forward Is Working Now
</body>
</html>
Output
JSP Forward Example





Your email address will not be published. Required fields are marked *