Java Reference
In-Depth Information
16
L ISTING 16.5
UseForward.jsp
<%@ page errorPage=”errorpage.jsp” %>
<html>
<head>
<title>Use JSP Forward</title>
</head>
<body>
<%
if ( (request.getParameter(“companyId”)).equals(“1”) ) {
%>
<jsp:forward page=”SamsHome.jsp”>
<jsp:param name=”employee” value=”Bob” />
<jsp:param name=”title” value=”Senior Engineer” />
</jsp:forward>
<%
}
else {
%>
<jsp:forward page=”MCPHome.jsp”>
<jsp:param name=”employee” value=”Joe” />
<jsp:param name=”title” value=”Senior Engineer” />
</jsp:forward>
<%
}
%>
</body>
</html>
As you can see, the UseForward.jsp simply checks the request for the company id and for-
wards the user, along with a set of request parameters, to the appropriate company home page.
Listings 16.6 and 16.7 contain the source of the company home pages.
L ISTING 16.6
SamsHome.jsp
<table>
<tr>
<td>
<img src=”sams.gif”>
</td>
<td>
<%
 
Search WWH ::




Custom Search