File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Custom tags - setting an attribute using <jsp:attribute> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Custom tags - setting an attribute using <jsp:attribute>" Watch "Custom tags - setting an attribute using <jsp:attribute>" New topic

Custom tags - setting an attribute using <jsp:attribute>

Nick White Ro

Joined: Jan 27, 2010
Posts: 15
Let's say I have a custom tag library:

This is the "showDate" tag class:

This is what I use in a JSP:

This works just fine. The "date" attribute value is passed as a Date object to the setter in the tag class.
BUT if I use <jsp:attribute> to specify the "date" attribute value, it is passed as a String object, so an exception is thrown: Cannot convert "Sun Feb 28 19:26:25 EET 2010" for the attribute date of the bean java.util.Date.
This is the synthax I used:

I haven't found in the specs anything which states that the <jsp:attribute> tag will ALWAYS return a String.
Consider Paul's rocket mass heater.
subject: Custom tags - setting an attribute using <jsp:attribute>
Similar Threads
Help with custom tags
question on rtexprvalue
Simple Tag with Attribute
JSP EL not working
SimpleTagSupport class