• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help with tags

 
Gunnar Maluf
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all

Im trying to use a tag similar to the example given in HF book page 389.

i have the following class:

package entities;

public class DiceRoller {

public static int rollDice(){

return (int)((Math.random()* 6) + 1);

}
}


The Following tld file called roll.tld under my WEB-INF:


<?xml version="1.0" encoding="UTF-8"?>
<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">
<tlibversion>1.2</tlibversion>
<uri>DiceFunctions</uri>
<function>
<name>rollIt</name>
<function-clas>entities.DiceRoller</function-clas>
<function-signature>int rollDice()</function-signature>
</function>

and a JSP which i hit directly from the browser:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="gk" uri="DiceFunctions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
${gk:rollIt()}
</body>
</html>
</taglib>

it should show some number on my browser but it doest work...it gives me the Unable to load class for JSP error.

Someone can tell me whats wrong?

ps: I didnt touch the web.xml
 
Gunnar Maluf
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found it! It was a mistake in the <function-class> element. I typed it <function-clas>


regards.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic