• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

TLD jsp  RSS feed

 
Greenhorn
Posts: 27
  • 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.
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
show code of TLD file
 
vivek mahadevan
Greenhorn
Posts: 27
  • 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: 27
  • 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: 27
  • 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
Boost this thread!