Tore
Tore

Reputation: 171

JSP <c:out/> - The default attribute doesn't work?

I'm having trouble with the default attribute of the JSP/JSTL tag . The value given for the default-attribute is not displayed.

<% @ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<c:out value='value' default="defaultValue"/> 

=> Displays value

<c:out value='' default="defaultValue"/>

=> Displays nothing.. // Should have been defaultValue

Why doesn't this work?

Upvotes: 3

Views: 7323

Answers (1)

Bozho
Bozho

Reputation: 597124

First, you'd better use double-quotes (").

Then, "" is a value - it is an empty string. The default value is used when the value is null

Upvotes: 7

Related Questions