Bug 4181

Summary: doAfterBody() function does not adhere to the JSP 1.2 specification
Product: Taglibs Reporter: Dennis Munsie <dennis.munsie>
Component: DateTime TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: CLOSED FIXED    
Severity: major    
Priority: P3    
Version: 1.0   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Dennis Munsie 2001-10-15 14:03:17 UTC
The datetime tag library that is depending on a broken feature in Tomcat and 
other servers (WLS 5.1, for example).  With servers that properlly implement 
the JSP 1.2 specification, this library will not work.

The following JSP code will not work:

<date:format pattern="MM/dd/yyyy" date="<%=new Date()%>"/>

The output is:
null

The format tag is using the doAfterBody() call to place it's output into the 
JSP.  But, since there is no body in the tag, the doAfterBody() function is not 
called.

From looking at the code, the fix would be to have the code that is in the 
doAfterBody() function be done in the doEnd() function instead (minus the code 
that actually processes the body).

The problem is occuring because the tag library is doing all of the date 
formating within the doAfterBody() function, and the specification says 
that "The method (doAfterBody()) is not invoked if there is no body evaluation" 
(section 10.1.2.2 of the JSP specifcation).  Since the function is not called, 
the variable date_formatted in the tag library is never set, causing the null 
that is being returned.
Comment 1 Glenn Nielsen 2002-04-04 18:03:01 UTC
Thanks for reporting this. The output for the format tag is now done in the
doEnd() instead of doAfterBody(). This change was made 2/23/2002.