1. TAGS - describe, specify, declare and use in this web app

Mirjana's picture

To define a tag, you need to:

  • Develop a tag handler and helper classes for the tag (we will use 2 tag libraries already developed, one by IBM/Sterling Commerce, i.e. userautho and Apache one i.e. taglibs-xtags). In a table below, you can see where you can find them and load into your project, either in file system or in eclipse.
  • Describe the tag in a tag library descriptor, tld file.
  • Specify tags in web.xml descriptor file
  • Declare the tag in web page where it is used


Describe the tag – .tld files in WEB-INF/tld

Descibe the tag in a tag library descriptor file (WEB-INF/tld/userautho.tld).

It is just an example of tld file, for this test web application, you can take userautho.tld and taglibs-xtags.tld from SI installation system and bundle them into your final war file. Paths for the tld files are given in a table below.

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"   "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">







      <description>    This tag library contains functionality specific to the    User Authentication and Authorization   </description>











            <description>             Performs user session validation        if fails, then attempts to forward to login/error page         </description>





                  <description>relative page url to which user should be forwarded in case of session being invalid/expired failure</description>





Specify the tag – in web.xml


Specify the location of your JSP tag library in your Web application’s WEB-INF/web.xml file. Type the following code between the <web-app> and </web-app> tags:











Declare the tag – in .jsp page

You declare that a JSP page will use tags defined in a tag library by including a taglib directive in the page before any custom tag is used:

<%@ taglib uri=" http://www.stercomm.com/uix/security" prefix="sec" %>

The uri attribute refers to a URI that uniquely identifies the tag library. This URI can be relative or absolute. If it is relative it must be mapped to an absolute location in the taglib element of a Web application deployment descriptor, the configuration file associated with Web applications developed according to the Java Servlet and JavaServer Pages specifications. The prefix attribute defines the prefix that distinguishes tags provided by a given tag library from those provided by other tag libraries.


Usage of tags  – in .jsp page

<sec:validSession login="login.jsp?message=Session expired. Please log in again"/>