[ Team LiB ] Previous Section Next Section

Workshop

The Workshop is designed to help you review what you have learned, and help you to further increase your understanding of the material covered in this hour.

Quiz

1:

What steps do you need to take before you can use JSTL in a JSP?

2:

What JSTL tag would you use to write the value of a variable?

3:

How do you find the length of a collection or a string?


Answers

A1:

Copy the JSTL JAR file(s) to your WEB-INF/lib directory, then add a <taglib> declaration to your web.xml file. Finally, add a <% taglib %> declaration to the top of your JSP.

A2:

The <c:out> tag writes out the value of a variable and can also display a default value if the variable is null.

A3:

The JSTL functions library provides a number of utility functions, including fn:length, which returns the length of a string or a collection.


Activities

  1. Create a JSP that uses the <c:set> tag to store several variables in the current request (use "request" as the scope name), and then forwards to a second JSP. In the second JSP, use the <c:out> tag to display the variables you stored.

  2. Create a JSP that uses <c:forEach> and <c:out> to display the request header variables. Use the implicit header and headerValues objects to enumerate through the header names and their values.

    [ Team LiB ] Previous Section Next Section