JSTL

Include dependencies

Include Hdiv libraries into the application.

In case you use Maven to manage dependencies add them to the pom.xml file.

<dependency>
    <groupId>org.hdiv</groupId>
    <artifactId>hdiv-config</artifactId>
    <version>${org.hdiv-version}</version>
</dependency>
<dependency>
    <groupId>org.hdiv</groupId>
    <artifactId>hdiv-jstl-taglibs-1.2</artifactId>
    <version>${org.hdiv-version}</version>
</dependency>

Note

Replace ${org.hdiv-version} variables with the ones sent by our support team.

Copy TLD file

Hdiv extends JSTL standard components in order to add security features. To enable these features it is necessary to replace JSTL TLD with Hdiv TLD for JSTL.

Copy TLD file into the project, for example in this location: /WEB-INF/tlds/hdiv-c.tld.

Modify web.xml

Modify the web.xml file to include the InitListener, ValidatorFilter and Hdiv TLD:

<listener>
    <listener-class>org.hdiv.listener.InitListener</listener-class>
</listener>

<!-- Hdiv Validator Filter -->
<filter>
    <filter-name>ValidatorFilter</filter-name>
    <filter-class>org.hdiv.filter.ValidatorFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>ValidatorFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<!-- Replace JSTL tld with Hdiv tld-->
<jsp-config>
    <taglib>
        <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
        <taglib-location>/WEB-INF/tlds/hdiv-c.tld</taglib-location>
    </taglib>
</jsp-config>

Spring framework configuration

Hdiv requires the use of Spring Framework in the application.

If the application doesn't use the Spring Framework, add the dependency and Spring's ContextLoaderListener in web.xmlfile.

<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>
    ...Spring configuration files...
  </param-value>
</context-param>

<listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

Check that ContextLoaderListener is before InitListener in the web.xml file.

Hdiv configuration file.

This file is an XML file that follows the format of Spring configuration files.

For convention, its name should be hdiv-config.xml, located in the WEB-INF directory and its minimal content is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:hdiv="http://www.hdiv.org/schema/hdiv-ee"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.hdiv.org/schema/hdiv-ee
http://www.hdiv.org/schema/hdiv/hdiv-ee.xsd">

    <!-- Hdiv Base Configuration -->
    <hdiv:config excludedExtensions="css,png,gif,js,woff">
        <hdiv:startPages>,/</hdiv:startPages>
    </hdiv:config>

    <!-- Own Editable Validation -->
    <hdiv:editableValidations>
        <hdiv:validationRule url="/.*" />
    </hdiv:editableValidations>
</beans>

Add the Hdiv configuration file hdiv-config.xml to the rest of Spring configuration files:

<!-- Spring Context Loader -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/dataAccess-config.xml
        /WEB-INF/security-config.xml
        /WEB-INF/hdiv-config.xml
    </param-value>
</context-param>

Recompile JSPs

Force JSP recompilation in order to use the new TLD file. This operation is server dependent.

Stop the server and delete the folders that contain compiled JSPs.

  • Tomcat: {path-to-tomcat}/work/Catalina/localhost/
  • JBoss: {path-to-jboss}/standalone/tmp/
  • Websphere: {path-to-websphere}/AppServer/profiles/{ServerName}/temp/{NodeName}/server1/

Delete all the content of the folder to clean compiled JSP files of all applications in the server or choose a specific application folder to clean only one application.

After start the server it will compile the JSP files when necessary.