*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes TLD jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "TLD jsp" Watch "TLD jsp" New topic
Author

TLD jsp

vivek mahadevan
Greenhorn

Joined: May 20, 2005
Posts: 26
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.


SCJP1.4,SCWCD1.4,SCBCD 1.3,SCDJWS 5, OCMJEA/SCEA 5
vidya sagar
Ranch Hand

Joined: Mar 02, 2005
Posts: 580
show code of TLD file
vivek mahadevan
Greenhorn

Joined: May 20, 2005
Posts: 26
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

Joined: May 20, 2005
Posts: 26
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

Joined: Mar 02, 2005
Posts: 580
Where did you place your TLD file
vivek mahadevan
Greenhorn

Joined: May 20, 2005
Posts: 26
inside WEB-INF
vidya sagar
Ranch Hand

Joined: Mar 02, 2005
Posts: 580
Dont access jsp directly call that jsp from one more jsp.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: TLD jsp
 
Similar Threads
Jsps and Servlets
Need help in deploying Counter example in chapter 7
Problem with jspInit() overriding
Configuring JSP init parameters
problem with this cookie program, getting a blank output