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.

Demo

  1. Download the file 'WorkshopList.txt' from the following hyperlink and save it to your working directory. Change extension from 'txt' to 'htm'.

    Download file icon

    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'.

  2. 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.

  3. At the start of the JSP add some code to assign strWorkshop the value of the option selected by the user.

  4. Next add an if statement that checks that strWorkshop is neither null nor empty.

  5. In the else clause, where the paramter is null or empty, add the following,
    <HTML>
    <BODY>
    <P>Missing parameter</P>
    </BODY>
    </HTML>
    
  6. 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

  7. Save and test your work.

If you couldn't get your solution to work then click the icon to display the source code Source code icon

Quiz !

The following quiz tests your knowledge of the include and forwrd actions.

Back Next