jQuery in Action, 3rd edition
The moose likes JSP and the fly likes TLD/EL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "TLD/EL "The function *** cannot be located with the specified prefix"" Watch "TLD/EL "The function *** cannot be located with the specified prefix"" New topic

TLD/EL "The function *** cannot be located with the specified prefix"

Tim March

Joined: Jun 14, 2012
Posts: 2
Hi all,

I've been lurking around this site for a while now , and I would like to think that I know a thing or two about Java. Unfortunately, I am new to dealing with TLD files and EL.

Basically, I'm trying to call a method on a jsp page. Originally I used a scriptlet, but I heard that was bad programming practice and I am now switching my code to JSTL. I still need to call that method, however.

Here is some of my code:


Here is some of my JSTL code:

And here is the error message I get:

Any help would be appreciated. Thanks in advance.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

Welcome to the Ranch!
Tim March wrote:


If you want to call the function by addDoi, why did you name it "f"?

(And what is a Doi? Spell it out! Freeze-drying names is not a good practice.)

[Asking smart questions] [About Bear] [Books by Bear]
Stefan Evans

Joined: Jul 06, 2005
Posts: 1580
General reactions to this code:

#1: It belongs in a servlet, rather than a JSP. Model1 vs Model2/MVC
#2: Your method could possibly be improved by passing in an object rather than all of these related parameters.
ie addDoi(DoiObject doi)

where DoiObject has attributes of input, type etc etc as applicable.

Once you have that object, the majority of those <c:set> commands you have can probably be made redundant, as you can then populate the bean automagically from request parameters (either using a framework, or just a jsp:useBean and jsp:setProperty)

Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

Bear Bibeault wrote:Freeze-drying names is not a good practice

This is the first time I've ever seen the term "freeze-drying" used to refer to the practice of crypticizing names... I like it Does this also apply to such classics as "pkgNbr", "bktCd", "pktSz", "trkWt", "trkLn" and other vowel-phobic names? (Translations: packageNumber, bracketCode, packetSize, truckWeight, trackLength).

Junilu - [How to Ask Questions] [How to Answer Questions]
Tim March

Joined: Jun 14, 2012
Posts: 2
Thanks for all your help guys. It turned out that the method I was calling was not static. Changed that and everything works perfectly.

For future googlers:

When referencing methods through .tld files --- make the method static!
Singh Harmeet
Ranch Hand

Joined: Aug 05, 2011
Posts: 115

if tou want to create the EL functions , firstly the function must be a static. in the TLD in which we define the <function-signature> we need to describe the full package name of type class. like you define the function in which you define String type parameter , but in TLD file if define the function signature , then describe the fully package name of class type , like java.lang.String for exmple :-
[code] <function-signature>void addDoi(java.lang.String doiInput, java.lang.String doiType, java.lang.String filename, java.lang.String source, java.lang.String productType, java.lang.String productLine, java.lang.String registrationMessage,
java.lang.String url, java.lang.String urlDescription, java.lang.String urlMetadata)</function-signature>[\code]

the basic type are automaticaly handel , there is no need to define full package name , like int , float etc

With Regards :-
Harmeet Singh
I agree. Here's the link: http://aspose.com/file-tools
subject: TLD/EL "The function *** cannot be located with the specified prefix"
jQuery in Action, 3rd edition