Deploying an app with static functions
The only thing that’s new here is the “myFunctions.tld” file. It has to be somewhere within WEB-INF or one of its subdirectories (unless it’s deployed in a JAR file, but we’ll talk about that later in the book). Here, because this app is so simple, we have both the DD (web.xml) and the TLD (myFunctions.tld) at the top level of WEB-INF, but you could organize them into subdirectories.
The key point is that the class with the static function MUST be available to the app, so... for now, you know that putting it inside WEB-INF/classes will work. And remember that in the taglib directive in the JSP, we specified a URI that matches the URI declared in the TLD. For now, think of the URI as simply whatever you decided to name the TLD. It’s just a name. In the next chapter on using custom tags, we’ll go into all the details about TLDs and URIs.

The class with the function (the public static method) must be available to the web app just like servlet, bean, and listener classes. That means somewhere in WEB-INF/classes...
Put the TLD file somewhere under WEB-INF, and make sure the taglib directive in the JSP includes a uri attribute that matches the <uri> element in the TLD.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access