[ 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:

Name two ways to represent a string in a JSP EL expression contained with an attribute value.

2:

Where does JSP EL look for variables?

3:

What's the difference between order.price and order["price"]?


Answers

A1:

You can use different quotation marks, such as value='${fn:length("hello")}', or you can use \ to escape the quotes, such as value="${fn:length(\"hello\")}".

A2:

It looks in the variable scopes, starting at the page scope and proceeding through the request, session, and application scopes, using the first variable it finds

A3:

There is no difference. The only time there might be a difference is if you are accessing a member of a map with an odd-looking key like "a+b". In this case, the syntax "order.a+b" would be interpreted as "access attribute a of order and then add it to b", instead of "access attribute a+b of order."


Activity

Use a scriptlet to store some values in the request and session scopes, then use the <jsp:text> tag to write JSP EL expressions that manipulate those values. Remember that you can use JSP EL expressions within the body text of the <jsp:text> tag.

    [ Team LiB ] Previous Section Next Section