Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in JSTL with Custom action tag

 
Vanchi Nathan
Ranch Hand
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the following instead ]

I don't think you should be using ExpressionEvaluatorManager.
 
Vanchi Nathan
Ranch Hand
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Michael Ku
Ranch Hand
Posts: 510
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which book used ExpressionEvaluationManager?
 
Vanchi Nathan
Ranch Hand
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Stefan Evans
Bartender
Posts: 1640
9
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic