This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Problem in EL userdefined Function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Problem in EL userdefined Function" Watch "Problem in EL userdefined Function" New topic
Author

Problem in EL userdefined Function

Kathiresan Chinnasamy
Ranch Hand

Joined: Jan 01, 2008
Posts: 65
Hi Friends,

I have problem with user defined function.. I have described my code and error Here ..

Please let me know the problem which i am having


Codes:

1.web.xml

<web-app 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"
version="2.4">

<servlet>
<servlet-name>ExpressionLanguage1</servlet-name>
<servlet-class>it.sella.kathir.ELServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>ExpressionLanguage1</servlet-name>
<url-pattern>/ELOne</url-pattern>
</servlet-mapping>

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

</web-app>



2. SamplEL.java


package it.sella.kathir;

public class SamplEL {

public static int func1() {


return 1000 ;
}

}


3.myfunction.tld (this file is in WEB-INF/myfunction.tld)

<?xml version="1.0" encoding="ISO-8859-1"?>
<taglib 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/web-
jsptaglibrary_2_0.xsd"
version="2.0">
<uri>KathirSample</uri>
<tlib-version>1.2</tlib-version>
<function>
<name>equals</name>
<function-class>it.sella.kathir.SamplEL</function-class>
<function-signature>int func1()</function-signature>
</function>
</taglib>


4.index.jsp

<%@ taglib prefix="mine" uri="/KathirSample"%>
<html>
<body>
<br>The Tag Fun Return Val is : ${mine.equals()}
</body>
</html>



Erorr is :

org.apache.jasper.JasperException: /index.jsp(4,34) The function equals must be used with a prefix when a default namespace is not specified


What is the problem .. and how to sovle this..

please help me....

Thanks in advance
Dee Brown
Ranch Hand

Joined: Jun 14, 2008
Posts: 94
${mine.equals} not ${mine.equals()}

Also, I had thought the uri values should match. That is, both should be:

<uri>KathirSample</uri> (you have a leading slash in the taglib directive.
Kathiresan Chinnasamy
Ranch Hand

Joined: Jan 01, 2008
Posts: 65
Hi Dee Brown,

i have tried what you said but here also getting error but error is different..

I have Done Changes in my Code :

in myfunction.tld

<tlib-version>1.2</tlib-version>
<uri>/KathirSample</uri>
<function>
<name>equals</name>
<function-class>it.sella.kathir.SamplEL</function-class>
<function-signature>int func1()</function-signature>
</function>

in my jsp:

<%@ taglib prefix="mine" uri="KathirSample"%>
<html>
<body>
<br>The Tag Fun Return Val is : ${mine.equals()}
</body>
</html>


the error is:

org.apache.jasper.JasperException: File "/KathirSample" not found
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
Kathiresan Chinnasamy
Ranch Hand

Joined: Jan 01, 2008
Posts: 65
Sorry i forget to say one thing .. i tried with front slash (both combination in myfunction.tld and index.jsp) i am getting the same error which i mentioned in the second reply
Dee Brown
Ranch Hand

Joined: Jun 14, 2008
Posts: 94
Also, I had thought the uri values should match. That is, both should be:

<uri>KathirSample</uri> (you have a leading slash in the taglib directive.)


Have you tried this?
Jan Sterk
Ranch Hand

Joined: Jun 06, 2008
Posts: 139
Try

${mine:equals()}

( : instead of . )


SCJP 1.4 (81%)<br />SCWCD 5 (95%)
Dee Brown
Ranch Hand

Joined: Jun 14, 2008
Posts: 94
Thanks Jan. Sorry Kathiresan.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in EL userdefined Function
 
Similar Threads
can we confuse container by giving wrolg ltd location for a perticular uri
Whats Wrong?
Using TLD in JSP
Looking for your help in fixing a issue in tag library.
Regarding TLD