Java Reference
In-Depth Information
The last piece of the puzzle is the choose tag. A choose tag is used with when tags, where each when tag
identifies a different condition to test. The following is an example with two when tags:
<c:choose>
<c:when test=' EL Expression '}'>
body
</c:when>
<c:when test=' EL Expression '}'>
body
</c:when>
</c:choose>
We will use the choose and when tags to determine which function was selected and then go to the correct JSP.
Tutorial: More JSP Tags
Let's continue our application:
1.
In c9.EnterEmpInfoForm source code, change the form action from EmpServlet to
EnterEmpInfoJSP.jsp.
2.
In TutorialsWeb/WebContent/c9, create a new JSP called EnterEmpInfoJSP.
3.
In the palette's JSP Tags tray, click on the Include item and then click on design pane.
4.
On the Insert JSP Include window, specify EnterEmpInfoForm.html in the File name
text field.
5.
Click the Flush check box in the lower left and then the OK button.
The Page Designer will display the EnterEmpInfoForm page.
So, not only are tags simpler to use, they can be easily inserted using Page Designer. It just keeps getting better!
If you switch to the Source view, you will see the flush parameter in the include tag. Previously, flush was a
required parameter, however, in this case, it can be removed and the tag will still work. (Essentially flushing ensures
that the entire contents of the included file are displayed. There are some nuances regarding the flush parameter,
however, we will leave a detailed explanation to a more exhaustive Java text and always specify true .)
6.
If necessary, switch to the Design View, and click on the If item in the JSP Tags tray.
7.
Click anywhere before the EnterEmpInfoForm. (I.e., Click above the thick black line not
the dashed line.)
The if tag icon will be placed on the Design view.
8.
Display the Properties view and enter the following EL condition statement as the if
condition (see Figure 9-21 ):
${pageContext.request.method=="POST"}
 
Search WWH ::




Custom Search