Mega Code Archive

 
Categories / Java / JSP
 

JSP Simple Tags

///   <!-- this must be added to the web application's web.xml --> <taglib>   <taglib-uri>/rntsoft</taglib-uri>   <taglib-location>/WEB-INF/rntsoft.tld</taglib-location> </taglib> // create File:rntsoft.tld in the /WEB-INF/ <!DOCTYPE taglib   PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"    "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">     <!-- a tab library descriptor --> <taglib xmlns="http://java.sun.com/JSP/TagLibraryDescriptor">   <tlib-version>1.0</tlib-version>   <jsp-version>1.2</jsp-version>   <short-name>rntsoft Simple Tags</short-name>   <!-- Expression Language function -->   <function>     <name>ReverseString</name>     <function-class>com.rntsoft.ELFunctions</function-class>     <function-signature>String reverse(String)</function-signature>   </function>   <!-- end of Expression Language function --> </taglib> //compile the following code into WEB-INF\classes\com\rntsoft package com.rntsoft; public class ELFunctions {   public static String reverse(String param)   {     return new StringBuffer(param).reverse().toString();   } } // start comcat and load the following jsp page in browser <%@ taglib uri="/rntsoft" prefix="rntsoft" %> <html>   <head>     <title>An Expression Language Tag</title>   </head>   <body>     output:     <h1>${rntsoft:ReverseString("Hello World from www.rntsoft.com!")}</h1>   </body> </html>