Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Exception in JSTL with Custom action tag

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I got the following exception while trying to integrate a custom action with JSTL EL.


SEVERE: Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: An error occurred while evaluating custom action attribute "map" with value "org.apache.commons.el.ImplicitObjects$5@1b34126": Attempt to convert String "org.apache.commons.el.ImplicitObjects$5@1b34126" to type "java.util.Map", but there is no PropertyEditor for that type (null)
at org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Evaluator.java:109)
at org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Evaluator.java:129)
at org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager.evaluate(ExpressionEvaluatorManager.java:75)
at code.tag.ShowMapAction.doStartTag(ShowMapAction.java:24)



The error shown is at ShowMapAction class at map = (Map) ExpressionEvaluatorManager.evaluate("map", mapName,Map.class, this, pageContext);

I have defined the tld file as well. Can anyone help me to sought this out?

Thanks in advance

vanchin
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems that you are trying to set a Map property, using a String. I'm just guessing but are trying to do something like :
<mytag:mmyaction map="mymap" .../> instead of <mytag:mmyaction map="${mymap}" .../>

Please show us how you are trying to use your custom action.
 
Vanchi Nathan
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello Christophe Verre,

thanks for the reply... i have quoted the jsp code..for your perusal..


<body>
<%@taglib uri='../WEB-INF/core-jstl.tld' prefix='core-jstl' %>

<font size='5'>Request Parameters: </font>
<p><core-jstl:showMap map='${param}'/></p>
<font size='5'>Request Headers:</font>
<p><core-jstl:showMap map='${header}'/></p>
<font size='5'>Cookies:</font>
<p><core-jstl:showMap map='${cookie}'/></p>
</body>


The tag handler is as follows:
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try the following instead ]

I don't think you should be using ExpressionEvaluatorManager.
 
Vanchi Nathan
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

thanks your code did work...

Please brief, why shouldn't we use the ExpressionEvaluationManager class as the code i used was from a text book.

regards

vanchi
 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which book used ExpressionEvaluationManager?
 
Vanchi Nathan
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Michael,

The code is found in the book : 'Core JSTL Mastering the JSP Standard Tag Library" on page 94.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That book focuses on JSTL1.0.

One of the major changes between JSTL1.0 and JSTL1.1 was the responsibility for evaluation of EL expressions.
In JSP1.2, the container knew nothing about ${expr} and thus the tags had to evalute the expression itself (using the ExpressionEvaluatorManager)
In JSP2.0 the container understands and evaluates the EL expression (provided that you have configured your web.xml appropriately)

The tag code you have got there is written in JSTL1.0 style - ie the attribute it takes is a String that is expected to be an EL expression to evaluate.
Presumably you have a JSP2.0 container which is configured to evaluate the expressions already - so it has already evaluated the expression to be a Map.

Bottom line - if you have a JSP2.0 container and it is configured to evaluate EL itself, then your tag classes should never use the ExpressionEvaluatorManager.
 
reply
    Bookmark Topic Watch Topic
  • New Topic