jQuery in Action, 3rd edition
The moose likes JSP and the fly likes Exception in JSTL with Custom action tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Exception in JSTL with Custom action tag" Watch "Exception in JSTL with Custom action tag" New topic

Exception in JSTL with Custom action tag

Vanchi Nathan
Ranch Hand

Joined: Feb 24, 2004
Posts: 107
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


Best regards,<br /> <br />vanchin
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

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.

[My Blog]
All roads lead to JavaRanch
Vanchi Nathan
Ranch Hand

Joined: Feb 24, 2004
Posts: 107
hello Christophe Verre,

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

<%@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>

The tag handler is as follows:
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Try the following instead ]

I don't think you should be using ExpressionEvaluatorManager.
Vanchi Nathan
Ranch Hand

Joined: Feb 24, 2004
Posts: 107

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.


Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
Which book used ExpressionEvaluationManager?
Vanchi Nathan
Ranch Hand

Joined: Feb 24, 2004
Posts: 107
hi Michael,

The code is found in the book : 'Core JSTL Mastering the JSP Standard Tag Library" on page 94.
Stefan Evans

Joined: Jul 06, 2005
Posts: 1523
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
subject: Exception in JSTL with Custom action tag
It's not a secret anymore!