Reputation: 6532
The JSTL formatting library: http://java.sun.com/jsp/jstl/fmt
doesn't work at all if there is no Accept-Language
header. can anyone explain why this is and how to get around it (Except for providing the header)
For instance: will format the date through a normal web browser, but using telnet or curl to request the page it doesn't format it correctly.
Upvotes: 0
Views: 3969
Reputation: 6764
As to why this is happening, this seems to be expected behaviour.
As per the JSTL spec on the Oracle site:
9.9
<fmt:formatDate>
Null & Error Handling
- If
value
is null, remove the scoped variable if it is specified (see attributesvar
andscope
).- If
timeZone
is null or empty, it is handled as if it was missing.- If this action fails to determine a formatting locale, it uses
java.util.Date.toString()
as the output format.
So as per your error, if no locale is set on the server-side & the request also doesn't pass one either, JSTL is falling back to a toString()
call on the date, rather than e.g. the locale of the JVM settings.
Upvotes: 1