Apache's Tomcat & Sun's Java are coming with their newer versions so we are going for their new features.
Like in Java 1.5 has come with its newer features of Autoboxing & Generics which made programmers' life simpler but while upgrading our applications it becomes difficult. ;)
I came across this problem while upgrading my application with Java(1.5). I have used Tomcat 5.5.9 to run my web-application. This version of Tomcat is compiling JSP with Java(1.4) even if I have only JDK 1.5 installed on my machine.
Due to this my changes in JSP regarding Autoboxing won't getting compiled & tomcat started throwing exception for JSP which is having use of Java 1.5 features.
So to make them compile with Java 1.5 we have to follow the steps:
[Step 1] Copying tools.jar, ant.jar, ant-launcher.jar to <TOMCAT_HOME>\common\lib & removing jasper-compiler-jdt.jar
You will get the tools.jar from <JAVA_HOME>\lib & other two ant related jars from lib folder of ANT. Better to have latest updated Ant.
[Step 2] Modifying the web.xml located @ <TOMCAT_HOME>\conf\
compilerSourceVM - What JDK version are the source files compatible with? (Default JDK 1.4)
compilerTargetVM - What JDK version are the generated files compatible with? (Default JDK 1.4)
* You have to modify JDK version to 1.5 for compliation of JSP with JDK(1.5).
To more info about above parameters you have to visit Apache Tomcat 5.5 Documentation.
The above parameters are to be added as shown in following code:
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>1.5</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.5</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
No comments:
Post a Comment