wood burning stoves*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes <jsp:attribute> standard actions and Lists Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "<jsp:attribute> standard actions and Lists" Watch "<jsp:attribute> standard actions and Lists" New topic
Author

<jsp:attribute> standard actions and Lists

Ulrich Vormbrock
Ranch Hand

Joined: Apr 15, 2010
Posts: 73
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?


SCJP 6 (88%), SCWCD (89%)
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1687
    
  25

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

Joined: Apr 15, 2010
Posts: 73
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
Bartender

Joined: Apr 07, 2010
Posts: 1687
    
  25

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

Joined: Apr 15, 2010
Posts: 73
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
Bartender

Joined: Apr 07, 2010
Posts: 1687
    
  25

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
 
 
subject: <jsp:attribute> standard actions and Lists