jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Bayern <bay...@essentially.net>
Subject Re: JSTL - question about formatDateSupport and BodyContent
Date Tue, 02 Apr 2002 22:40:38 GMT
Great question, Brennan.  This is actually a known issue, and we're trying
to get to the bottom of exactly how this is supposed to work (compatibly
in all compliant JSP 1.2 containers).  Thanks for the reminder.

Shawn Bayern
Author, "JSP Standard Tag Library"  http://www.jstlbook.com
(coming this summer from Manning Publications)

On Tue, 2 Apr 2002 Brennan.O'Shea@alltel.com wrote:

> In using the JSTL example formatDateTime.jsp, I don't get any dates
> displayed.  In the examples, the current date is supposed to be
> displayed since "value" is not specified and the <fmt:formatDate/> tags
> don't have a body.
> The problem is that getBodyContent() returns an empty string for the
> tags in the example JSP.  Since the code from FormatDateSupport below
> only uses the current date when the value attribute is not specified AND
> getBodyContent() is null, no dates show up in the browser.
> if (!valueSpecified && (getBodyContent() == null)) {
>     // 'value' missing, use current date
>     value = new Date();
> } 
> I discovered that when I close the tag without using the shorthand
> notation:
>    <fmt:formatDate type="both" dateStyle="full"
> timeStyle="full"></fmt:formatDate>
> instead of:
>    <fmt:formatDate type="both" dateStyle="full" timeStyle="full"/>
> It works -- I get the current date.  getBodyContent does NOT return null
> when using the shorthand notation, but returns an empty String instead.
> I'm using the standard beta 1 version of JSTL on Tomcat 4.0.1.  Is this
> a bug in the tag?  Should the code above check for an empty string as
> well as null when determining whether to use the current date?  It seems
> to me that getBodyContent() should have the same behavior regardless of
> shorthand (/>) or normal empty tag notation -- however I could not find
> a definition of what constitutes an empty tag in the JSP 1.2 spec.
> What gives?
> Thanks.
> Brennan

To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>

View raw message