Just published on the DevShed, an article – excerpt from “Beginning JSP 2 – From Novice to Professional” published by Apress (2004) – on using JSTL for implementing conditional logic an accessing collections.
Making Decisions, Decisions. I found especially the JSTL examples quite useful.
The kinds of program flow control you’ll meet in this article are as follows:
- Conditional statements: Evaluating a condition in the program and executing code depending on whether the condition evaluates to “true� or “false�
- Iterative statements: Repeating (looping through) sections of code
- Branching statements: Transferring execution of the program to a particular section of the code
This chapter discusses the syntax Java provides for all of these and also presents the flow control constructs of the Java Standard Tag Library (JSTL). You’ll also look at how Java lets you store and manipulate groups of variables of the same type using arrays. In short, the chapter covers the following:
* How to use arrays and when to use them
* How to compare values
* How to easily incorporate logic in your code
* The if,if…else, and switch statements
* The while,do…while, and for loops
* The break, continue, and return statements
In each case you’ll learn about the standard Java techniques, followed by a JSTL example if appropriate.