Olá,
Estou tentando fazer um exemplo do “Head First Servlets & JSP” de functions com EL mas está dando um erro ao visualizar minha JSP.
A JSP está assim:
[code]<%@ taglib prefix=“mine” uri=“DiceFunctions”%>
<html><body>
${mine.rollIt()}
</body></html>[/code]
A TLD myFunctions.tld está assim:
[code]<?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-app_2_4.xsd”
version=“2.4”>
<tlibversion>1.0</tlibversion>
<jsp-version>1.2</jsp-version>
<uri>DiceFunctions</uri>
<function>
<name>rollIt</name>
<function-class>pacote.DiceRoller</function-class>
<function-signature>
int rollDice()
</function-signature>
</function>
</taglib>[/code]
e a TLD está no WEB-INF
A classe DiceRoller está assim:
[code]package pacote;
public class DiceRoller{
public static int rollDice(){
return (int) ((Math.random()*6)+1);
}
}[/code]
O erro que aparece ao visualizar a JSP é o seguinte:
org.apache.jasper.JasperException: /head_first_pg389.jsp(4,2) The function rollIt must be used with a prefix when a default namespace is not specified
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:83)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:402)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:186)
org.apache.jasper.compiler.Validator$1FVVisitor.visit(Validator.java:1272)
org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:163)
....