Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of

EL and the Java Standard Tag Library, JSTL, mix very nicely. JSTL is Apache and if you're using Tomcat, you'll probably have the files necessary already in one of the examples' WEB-INF/lib, jstl.jar and standard.jar . If you copy these to Tomcat's common/lib, you can use JSTL in each application. Actually, the JSP specification tells you to copy jars to an application's WEB-INF/lib, but that's not very efficient, plus your applications will end up having different versions. If you want to build portable applications, however, the logic is valid, then it makes sense to supply the jars needed in the application's war.

Using a very simple bean with get- and set-methods for accessing its properties.

In these EL expressions, the get-methods are called.

Setting the phone property to the value of a parameter ph, if present.

Doing the same with a JSTL 'set' tag. Notice that the target's value is also an EL expression !!!

Using the same tag to create an application-scope attribute.

And, just to show how it's done, removing it.

Using a very temporary value to set the bean's 'name' property to.

A JSTL 'if-else'. Multiple 'when's are allowed, but in that case ONLY the FIRST one found to be TRUE, is executed. If none are true, then 'otherwise' gets a shot at it.

Have to be in a 'choose' tag.

The EL expression results in true or false, 'not' and 'empty' are special keywords.

Two ways to output a value, if present, ...

and if not, some default text.

Another difference is that the first one's default text ends up in the output with the italics tags, due to the escapeXML attribute. The second will have lost its XML characters, since escapeXml's default setting is 'true' ( ! ; and only the 'X' is uppercase )

The 'if' tag can be used to conditionally output some text. ge, greater than or equal. Conversion to numeric is automatic.

Not only numeric comparisons are allowed, but Strings may be compared, too, using these EL operators.

The 'forEach' tag is meant to handle a Collection's elements.




The var and scope attributes always need a fixed string , while nearly all other JSTL attributes can be EL, can be dynamic.


J2EE 1.4 contains JSTL, in case you want to use Sun's Application Server. With JBoss, it's just a matter of adding the jars to the war's WEB-INF/lib.