Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

<jsp:attribute> standard actions and Lists

 
Ulrich Vormbrock
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've written a simple tag handler in order to print out several user data (from a form).
All works fine - except the last attribute named "programLanguages" - it deals with a List rather than with a String.
Below please find the tag "advice" which I've place into the "result.jsp":




When I run the result.jsp, I get the following exception:
org.apache.jasper.JasperException: Unable to convert string "[cpp, java, vb]" to class "java.util.List" for attribute "programLanguages": Property Editor not registered with the PropertyEditorManager


Instead, when I place the "programLanguages" attribute within my custom tag, it works fine:


Any ideas?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2337
86
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulrich,

The body of the <jsp:attribute> is always evaluated and converted into a String, and this is not possible for a List.
You can pass the List as an attribute of the customtag, like you already did.

Regards,
Frits
 
Ulrich Vormbrock
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hartelijk bedankt - many thanks, Frits!

Can you please tell me where I can find this kind of info?
I ask because I didn't find no hint concerning <jsp:attribute> in the "Head First" book ...
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2337
86
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Graag gedaan - you are welcome!

JSP.5.10
For standard or custom action attributes that accept a request-time expression
value, the Container must evaluate the body of the <jsp:attribute> action and
use the result of this evaluation as the value of the attribute. The body of the
attribute action can be any JSP content in this case. If the type of the attribute
is not String, the standard type conversion rules are applied, as per
Section JSP.1.14.2.1, "Conversions from String values".


Regards,
Frits
 
Ulrich Vormbrock
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you again, Frits!
In future, I'll rely not only on the book, but also on the spec ...
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2337
86
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In future, I'll rely not only on the book, but also on the spec ...

It can certainly help you on the newer topics like the <jsp:attribute>, <jsp:body> and so on

Also have a look at the following example where you can force the input of a custom tag attribute to be of a certain type
enum attribute

Regards,
Frits
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic