• 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!