O'Reilly logo

Head First Servlets and JSP, 2nd Edition by Bert Bates, Bryan Basham, Kathy Sierra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

But what if you need an else?

What if you want to do one thing if the condition is true, and a different thing if the condition is false? In other words, what if we want to show either one thing or the other, but nobody will see both? The <c:if> on the previous page worked fine because the logic was: everybody sees the first part, and then if the test condition is true, show a little extra.

But now imagine this scenario: you have a car sales web site, and you want to customize the headline that shows up on each page, based on a user attribute set up earlier in the session. Most of the page is the same regardless of the user, but each user sees a customized headline—one that best fits the user’s personal motivation for buying. (We are, after all, trying to sell him a car and become obscenely wealthy.) At the beginning of the session, a form asks the user to choose what’s most important...

Imagine a web site for a car company. The first page asks the user what he feels is most important.

Just like a good salesman, the pages that talk about features of the car will customize the presentation based on the user’s preference, so that each feature of the car looks like it was made with HIS personal needs in mind...

image with no caption

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required