1. Open Tomcat’s conf/web.xml file back up and find the JspServlet again.

  2. Add the following init parameter, which tells the Servlet to use Apache Ant with the JDK

    compiler to compile JSPs instead of the Eclipse compiler.

    1
    2
    3
    4
    <init-param>
        <param-name>compiler</param-name>
        <param-value>modern</param-value>
    </init-param>
    cs
  1. Tomcat doesn’t have a way to use the JDK compiler directly, so you must have the latest version of Ant installed on your system. You also need to add the JDK’s tools.jar file and Ant’s ant.jar and ant-launcher.jar files to your classpath. The easiest way to do this is to create a bin\setenv.bat file and add the following line of code to it (ignore new lines here), replacing the file paths as necessary for your system.

    set "CLASSPATH=C:\path\to\jdk8\lib\tools.jar;C:\path\to\ant\lib\ant.jar; C:\path\to\ant\lib\ant-launcher.jar"

    Of course, this applies only to Windows machines. For non-Windows environments, you should instead create a bin/setenv.sh file with the following contents, replacing the file paths as necessary for your system:

    export CLASSPATH=/path/to/jdk8/lib/tools.jar:/path/to/ant/lib/ant.jar: /path/to/ant/lib/ant-launcher.jar 


+ Recent posts