• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

<jsp:attribute> standard actions and Lists

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic