• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in EL userdefined Function

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
${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
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try

${mine:equals()}

( : instead of . )
 
Dee Brown
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jan. Sorry Kathiresan.
 
reply
    Bookmark Topic Watch Topic
  • New Topic