JSP Simple Tags : Tag « JSP « Java

JSP Simple Tags

  <!-- this must be added to the web application's web.xml -->


// create File:java2s.tld in the /WEB-INF/
<!DOCTYPE taglib
  PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"

    <!-- a tab library descriptor -->
<taglib xmlns="http://java.sun.com/JSP/TagLibraryDescriptor">
  <short-name>Java2s Simple Tags</short-name>

  <!-- Expression Language function -->
    <function-signature>String reverse(String)</function-signature>
  <!-- end of Expression Language function -->

//compile the following code into WEB-INF\classes\com\java2s
package com.java2s;

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="/java2s" prefix="java2s" %>

    <title>An Expression Language Tag</title>
    <h1>${java2s:ReverseString("Hello World from www.java2s.com!")}</h1>


Related examples in the same category

1.Your own simple JSP tag
2.Create your own tag: a custom tag body
3.A custom tag that has neither attributes nor body content.
4.A custom tag: empty with attributes
5.A custom tag: scripting variable
6.Write your own tag
7.Logo Tag
8.A custom tag: empty
9.Tag lifecycle with Attribute
10.A custom tag: iteration
11.JSP tag: advanced tagsJSP tag: advanced tags
12.JSP classic tagsJSP classic tags
13.JSP Tag Libraries and JSTLJSP Tag Libraries and JSTL
14.JSP Directives: HTML tag