Java Reference
In-Depth Information
Listing 2-23. Using the Forward Action in main.jsp
1.<html>
2.<head>
3.</head>
4.<body>
5.<%out.print("Inside main.jsp"); %><br/>
6.<jsp:forward page="sub.jsp"/>
7.</body>
8.</html>
Line 6 : Uses <jsp:forward> to forward to the target JSP page ( sub.jsp ).
Listing 2-24. sub.jsp
1.<html>
2.<head>
3.</head>
4.<body>
5.<%out.print("Inside sub.jsp"); %><br/>
6.</body>
7.</html>
Figure 2-29 shows the output when main.jsp is accessed.
Figure 2-29. Usage of the forward action
To understand the difference between the include action and the forward action, compare Listing 2-21
with Listing 2-23 and compare Figure 2-28 with Figure 2-29 . In Listing 2-23, we use the forward
action in main.jsp , instead of the include action. The forward action transfers the control to sub.jsp ,
just like the include action. But when sub.jsp completes, unlike the include action, control does not
go back to main.jsp .
The <jsp:useBean>, <jsp:getProperty>, and <jsp:setProperty> Actions
These three standard actions can eliminate a great deal of scripting code including declarations,
scriptlets, and expressions.
 
Search WWH ::




Custom Search