This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes JSP JSTL Custom Functions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP JSTL Custom Functions" Watch "JSP JSTL Custom Functions" New topic
Author

JSP JSTL Custom Functions

Ronnie Pitts
Greenhorn

Joined: Feb 11, 2008
Posts: 3
I'm trying to setup a custom JSP function without any luck using resin 3.1.2

I've created the following TestFunction.tld

<?xml version="1.0" encoding="UTF-8" ?>
<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">
<tlib-version>1.0</tlib-version>
<short-name>tf</short-name>
<uri>http://testme.com/taglibs/TestFunction</uri>
<function>
<name>testMethod</name>
<function-class>
jw.jaas.beans.TestFunction
</function-class>
<function-signature>
java.lang.String testMethod( java.lang.String, int, boolean)
</function-signature>
</function>
</taglib>

Updated the web.xml

<taglib>
<taglib-uri>http://testme.com/taglibs/TestFunction</taglib-uri>
<taglib-location>/WEB-INF/TestFunction.tld</taglib-location>
</taglib>

Created the following TestFunction.java


package jw.jaas.beans;
import java.util.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class TestFunction {
public static String testMethod(String text, int number, boolean logic) {
return "it works";
}
}

Added the following to a test.jsp


<%@ taglib prefix='tf' uri='http://clicklovers.com/taglibs/TestFunction'%>
<tf:testMethod('This is a good test',123,true)>


And receive the following:


'testMethod' is an unknown tag in tag library 'http://testme.com/taglibs/TestFunction'.


Any ideas?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

Welcome to the Ranch. Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and many people that might be able to help you will just move along. Please read this for more information.

You can go back and change your post to add code tags by clicking the .


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

Clarification: it's not "JSTL custom functions" but rather "EL custom functions". The JSTL defines its own set of EL functions.

This is not valid syntax for invoking an EL function.

An EL function must be invoked as part of an EL expression.
Ronnie Pitts
Greenhorn

Joined: Feb 11, 2008
Posts: 3
can get me an example then please?
Ronnie Pitts
Greenhorn

Joined: Feb 11, 2008
Posts: 3
can get me an example then please?
Dave Mark
Greenhorn

Joined: Feb 21, 2004
Posts: 19
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP JSTL Custom Functions
 
Similar Threads
Custom Tag
JSTL Syntax
about EL Function
JSP EL not working
Strange exception while using EL functions.