Workshop 8. The Forward Action
Objective
The objective of this workshop is to use the forward action to redirect the workflow according to a choice made by the user. Here we display a list of workshops to the user and when one is selected the application displays that workshop.
Time Available
This workshop should take no longer than 60 minutes.
The Forward Action Workshop
The following demonstrates the objective of this workshop.
- Download the file 'WorkshopList.txt' from the following hyperlink and save it to your
working directory. Change extension from 'txt' to 'htm'.
This file displays a select box whose options have a value attribute as the file name of the workshop. The form posts the request to 'forward.jsp'.
- Create a new JSP called 'forward.jsp' and add the following HTML.
We want this file to pick up the choice made by the user and then forward the workflow to the required JSP.
- At the start of the JSP add some code to assign
strWorkshopthe value of the option selected by the user.
- Next add an
ifstatement that checks thatstrWorkshopis neither null nor empty.
- In the else clause, where the paramter is null or empty, add the following,
<HTML> <BODY> <P>Missing parameter</P> </BODY> </HTML>
- In the true clause where we have a value add a forward action tag that forwards the
request to the file held in
strWorkshop.Remember that action tags are written to the HTML part of a JSP not inside <%..%> tags
- Save and test your work.
Quiz !
The following quiz tests your knowledge of the include and forwrd actions.