Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TLD jsp

 
vivek mahadevan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i used the code in page 389 in HFS.but i got the soultion as ${mine:rollIt()}
the web.xml i used
is

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
- <servlet>
<servlet-name>tldfunc</servlet-name>
<jsp-file>/TestBean.jsp</jsp-file>
</servlet>
- <servlet-mapping>
<servlet-name>tldfunc</servlet-name>
<url-pattern>/ch8ex5</url-pattern>
</servlet-mapping>
</web-app>

kindly where tell me where i would have gone wrong.
 
vidya sagar
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
show code of TLD file
 
vivek mahadevan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the tld file is myFunctions.tld

<?xml version="1.0" encoding="ISO-8859-1" ?>

<taglib version="2.0" >

<tlib-version>1.2</tlib-version>
<short-name>viv</short-name>
<uri>DiceFunctions</uri>
<function>
<name>rollIt</name>
<function-class>foo.DiceRoller</function-class>
<function-signature>int rollDice()</function-signature>
</function>
</taglib>
 
vivek mahadevan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the jsp TestBean.jsp

<%@ taglib prefix="mine" uri="DiceFunctions" %>
<html><body>

${mine:rollIt()}

</body></html>

and the DiceRoller.java
package foo;

public class DiceRoller
{
public static int rollDice()
{
return (int) ((Math.random()*6)+1);
}
}
 
vidya sagar
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you place your TLD file
 
vivek mahadevan
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
inside WEB-INF
 
vidya sagar
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dont access jsp directly call that jsp from one more jsp.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic