Java Reference
In-Depth Information
16
F
IGURE
16.2
The output from
UseForward.jsp
.
You should also go ahead and change the
companyId
request parameter to equal something
other than
1
. This will show you how the JSP forwards based on a conditional.
To see how the
<jsp:forward>
action is implemented, let's take a look at the following code
snippet removed from the generated servlet's
_jspService()
method:
// begin [file=”C:\\UseForward.jsp”;from=(7,6);to=(11,8)]
if ( (request.getParameter(“companyId”)).equals(“1”) ) {
// end
// begin [file=”C:\\UseForward.jsp”;from=(12,10);to=(15,24)]
if (true) {
out.clear();
String _jspx_qfStr = “”;
_jspx_qfStr = _jspx_qfStr + “?employee=” + “Bob”;
_jspx_qfStr = _jspx_qfStr + “&title=” + “Senior Engineer”;
pageContext.forward(“SamsHome.jsp” + _jspx_qfStr);
return;
}