Java Reference
In-Depth Information
11.com.apress.elfunction.Now
12.</function-class>
13.<function-signature>
14.String now()
15.</function-signature>
16.
17.</function>
18.</taglib>
Line7 : Line 7 is the URI of the function that will be used in the taglib directive in
the JSP page.
Lines 8 to 17 : These lines specify the Java method that will be invoked with the
signature and the Java class in which this method is defined.
A Java method can be called from JSP using EL in the following manner: ${prefix:function-name) .
The namespace prefix is declared by using the taglib directive in the JSP page. Listing 3-33 shows
the JSP code.
Listing 3-33. Invoking an EL Function in JSP
1.<%@ taglib prefix="elf" uri="elFunction"%>
2.<html>
3.
4.<body>${elf:now() }
5.</body>
6.</html>
Line 1 : Line 1 is a taglib directive with the prefix elf and a URI. The URI is
defined in the tag library descriptor.
Line 4 : This uses the prefix elf and invokes the function. This function name is
defined in the tag library description.
You can create this application based on the first JSP application we created in Chapter 2. When
this application is run ( http://localhost:8080/elFunctions/elTest.jsp ), it gives the output shown
in Figure 3-8 .
 
Search WWH ::




Custom Search