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

Set a default value with the default attribute

Suppose you want to show these anonymous users a message that says, “Hello guest.” This is a perfect place to use a default value with the c:out tag. Just add a default attribute, and provide the value you want to print if your expression evaluates to null:

image with no caption

Or you can do it this way:

<b>Hello <c:out value='${user}'>guest</c:out></b>

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