Edit the web.xml File for JSTL

The web.xml file contains properties controlling servlets for a specific Web application. This is a standard file that is created when the Web application is created by using J2EE. If you are adding JSTL Standard Library functions to multiple Web applications, you must edit the web.xml file associated with each Web application.

To use JSTL, you must declare the <taglib> tags in the web.xml file between the <Web-app> and </Web-app> tags.

To edit the web.xml file:

  1. Locate the web.xml file in the Web application directory. The standard directory structure is:WebApplicationName/WebApp/WEB-INF/web.xml
  2. Declare the <taglib> tags for each of the following tag libraries between the <Web-app> and </Web-app> tags:

    For This Tag Library

    Type The Following Tag

    Core (EL)

    <taglib>
    <taglib-uri>http://java.sun.com/jstl/core<taglib-uri>
    <taglib-location>tld/c-1_0.tld</taglib-location>
    </taglib>

    Core (RT)

    <taglib>
    <taglib-uri>http://java.sun.com/jstl/core-rt<taglib-uri>
    <taglib-location>tld/c-1_0-rt.tld</taglib-location>
    </taglib>

    Format (EL)

    <taglib>
    <taglib-uri>http://java.sun.com/jstl/fmt<taglib-uri>
    <taglib-location>tld/fmt-1_0.tld</taglib-location>
    </taglib>

    Format (RT)

    <taglib>
    <taglib-uri>http://java.sun.com/jstl/fmt-rt<taglib-uri>
    <taglib-location>tld/fmt-1_0-rt.tld</taglib-location>
    </taglib>

    SQL (EL)

    <taglib>
    <taglib-uri>http://java.sun.com/jstl/sql<taglib-uri>
    <taglib-location>tld/sql-1_0.tld</taglib-location>
    </taglib>

    SQL (RT)

    <taglib>
    <taglib-uri>http://java.sun.com/jstl/sql-rt<taglib-uri>
    <taglib-location>tld/sql-1_0-rt.tld</taglib-location>
    </taglib>

    XML (EL)

    <taglib>
    <taglib-uri>http://java.sun.com/jstl/xml<taglib-uri>
    <taglib-location>tld/x-1_0.tld</taglib-location>
    </taglib>

    XML (RT)

    <taglib>
    <taglib-uri>http://java.sun.com/jstl/xml-rt<taglib-uri>
    <taglib-location>tld/x-1_0-rt.tld</taglib-location>
    </taglib>
  3. Save the web.xml file to the original location.
    CAUTION:
    Do not change the name or the location of the web.xml when saving the file. Doing so may cause errors.