Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

wierd exception in EL function

 
Dinkar Chaturvedi
Ranch Hand
Posts: 42
Android Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I was trying my hands over EL functions for which I created a JSP with the following code:

~~~~~~~~~~~~~
<%@ taglib uri="diceroll" prefix="mine"%>
<html>
<body>
The dice value is ${mine:rollIt()}
</body>
</html>
~~~~~~~~~~~~~

I created a TLD file with the following content:

~~~~~~~~~~~~~
<taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" version="2.0">

<tlib-version>1.0</tlib-version>
<jsp-version>2.0</jsp-version>
<short-name>mine</short-name>
<uri>diceroll</uri>
<function>
<name>rollIt</name>
<function-class>com.example.web.DiceRoller</function-class>
<function-signature>int rollDice()</function-signature>
</function>
<tag>
</tag>
</taglib>
~~~~~~~~~~~~~

The java code that this TLD points to is:

~~~~~~~~~~~~~
package com.example.web;

public class DiceRoller{
public static int rollDice(){
return (int)(Math.random()*6+1);
}
}
~~~~~~~~~~~~~

I am getting this exception while trying to access this JSP:
~~~~~~~~~~~~~
org.apache.jasper.JasperException: The class specified in the method signature in TLD for the function mine:rollIt cannot be found.
~~~~~~~~~~~~~

I am using Tomcat version 5.0.16. Can anyone tell me the reason for this and how can i get this working?

Regards
Dinkar
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everything looks fine.
1. Where did you put the DiceRoller.class ?
2. Did you try to reboot the container ?
 
Dinkar Chaturvedi
Ranch Hand
Posts: 42
Android Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The class file is in the WEB-INF\classes folder in the appropriate directory hirarchy i.e. WEB-INF\classes\com\example\web
and i yeah i did restart my container too.
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bug 26628 fixed in Tomcat 5.0.19 :
http://tomcat.apache.org/tomcat-5.0-doc/changelog.html
 
Dinkar Chaturvedi
Ranch Hand
Posts: 42
Android Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Satau,
Thanks a lot for clearing this doubt. I put some arbitrary parameters into it and its working fine now.

Regards
Dinkar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic