In order to define an EL function, a <function> element must be added to an existing or new TLD file that is in the scope of your application and declared within the referencing JSP page. For our example, if we wanted to name the EL function the same name as the static method (though they do not need to be the same), we could add:
to a TLD file in our web application. (Of course, this class must be available in the classpath of the web app).
Note that the class name of the enclosing class must be fully qualified, and note that the class names in the signature must also be fully qualified.
On a JSP page where you wish to reference your new EL function, you would declare the taglib as any other. For example:
and then you could use the function in any EL expression on that page. Be sure that the uri value matches the URI defined within your TLD file. For example:
Let's say that we have a scoped variable named someText that contains text that we want to emit into the context of a JavaS'cript string. In order to make sure that there will be no quoting problems, we want to call our escape function on the string so that any embedded quotes will be escaped and will not interfere with the syntax of the JavaS'cript notation on the page.