Win a copy of Terraform in Action this week in the Cloud forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

how to create tld file?

 
Ranch Hand
Posts: 598
3
jQuery Google App Engine Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eclipse IDE for j2ee 3.x
Tomcat 6.x
Java 6
Hi friends I have problem regarding tld.
I have following files.


//a.tld file

//jsp file : Test.jsp


When I test the jsp file I get this error:org.apache.jasper.JasperException: /Test.jsp(6,2) The function rolldice cannot be located with the specified prefix

I doubt that I am wrong in creating tld.By the way I did not create web.xml
for this project since the book(HFSJ SCWCD 1.4) does not tell me to do so.
Head First Servlet and Jsp(ch 8,page 389).
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I doubt that I am wrong in creating tld.


What about your "function-singnature" tag ? ;) I've never heard of the "funtion" tag either. And it looks like "uri" is not where it should be. I doubt that this TLD is correct
[ March 24, 2008: Message edited by: Christophe Verre ]
 
Bobby Sharma
Ranch Hand
Posts: 598
3
jQuery Google App Engine Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
LOL, got it. I should have noticed. :p

thanks

best regards
omi
 
Sheriff
Posts: 67601
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Christophe Verre:
I've never heard of the "funtion" tag either.

It's the means by which EL functions are declared.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It's the means by which EL functions are declared.


It was intended to be a joke ;) There's a spell miss in the tag name : "funtion" -> "function"
 
Bear Bibeault
Sheriff
Posts: 67601
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whoooooooooooosh!

(sound of joke whizzing past Bear's oblivious head)
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting the output of this program as 1, no matter how many times i run, wasn't supposed to be random numbers between 1 to 6.....
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you will always get "1" output because...

return ((int)Math.random()*6+1);

...should be...

return ((int)(Math.random()*6)+1);

 
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

I did the same, but no luck for me.

I have Eclipse EE. Tomcat 6.0.

Below is the program : -

DiceRoller class for static function:

package foo;

public class DiceRoller {

public static int rollDice()
{
return (int) ((Math.random() * 6) + 1);
}

}

------------

MyFunctions.tld --- I placed this file under WEB-INF

<?xml version="1.0" encoding="UTF-8"?>

<taglib version="2.0">

<tlib-version>1.2</tlib-version>

<uri>DiceFunction</uri>
<function>
<name>rollIt</name>
<function-class>foo.DiceRoller</function-class>
<function-signature>int rollDice()</function-signature>
</function>

</taglib>

------------------------------

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="mine" tagdir="/WEB-INF/myFunction.tld" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

${mine:rollIt() }

</body>
</html>

-------------------

index.html as welcome page :

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="Result.jsp" method="get">
Go

<input type="submit"></input>

</form>

</body>
</html>

-------------------------

I'm getting this error at runtime :
org.apache.jasper.JasperException: File "/DiceFuntion" not found


Eclipse highlights uri="DiceFuntion" as can not find the tag library descriptor , hence there is error for ${mine:rollIt()} as well.


While I found one of the IDE(name is not given) offering a template to create .tld file, I had to create on XML under New-Other and change the extension from .xml to .tld

Please please help.
Many thanks.

Pramod

 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops, the code works fine when I make this change :

<%@ taglib prefix="mine" uri="/WEB-INF/myFunctions.tld" %>

The problem is that <%@ taglib prefix="mine" tagdir="/WEB-INF/myFunctions.tld" %> this code shows the below error

org.apache.jasper.JasperException: Tag file directory /WEB-INF/myFunctions.tld does not start with "/WEB-INF/tags"

I guess tagdir is not the right keyword for this as error code is showing tags directory which I assume, we use for .tag files.

Please advise.

Many thanks.
 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Again,

I'm trying to use <c:out> tags in jsp & getting this runtime error
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

Below is the code :

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>ReSuLT</title>
</head>
<body>

This is list

<c:out value="movielist"></c:out>

</body>
</html>

-------------------
The configuration is Tomcat 6.0, Eclipse EE 3.5.2, WebApp version 2.4
When I didn't add jstl.jar & standard.jar , Eclipse displayed unknown tag <c:out>

So i added both jar files to Build path/Libraries and CLASSPATH variable.
My friend suggested to me to check if both jars are present in Webapps folder for which I got this :
C:\Tomcat6\apache-tomcat-6.0.29\webapps\examples\WEB-INF\lib\jstl.jar and stanard.jar

I haven't defined anything in web.xml.

Please advise.

Many Thanks,

 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I added two entries to web.xml but same problem is showing up again.

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" 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 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:fmt="http://java.sun.com/jsp/jstl/fmt">

<display-name>JSTL</display-name>

<servlet>
<description>
</description>
<display-name>Check</display-name>
<servlet-name>Check</servlet-name>
<servlet-class> test.Check</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Check</servlet-name>
<url-pattern>/Check</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>

</welcome-file-list>


</web-app>
 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

The issue is solved

Actually, I had to copy two jars jstl.jar and standard.jar from C:\Tomcat6\apache-tomcat-6.0.29\webapps\examples\WEB-INF\lib to C:\Tomcat6\apache-tomcat-6.0.29\lib

Thank you.

Pramod
 
reply
    Bookmark Topic Watch Topic
  • New Topic