开发者

Setting JSP page syntax to JDK 1.5 on Tomcat 5.5

I have read in the Tomcat doc that its possiable to send to the Tomcat server with a JSP page what JDK to compile it with, the question is how?

The reason why i want to do it is that i am developing a page to integrate into running web application so I prefer not to change the defult Tomcat jdk setting, BUT the JDK 1.4 wich is the default isnt supporting the List syntax as JDK 1.5, and i cannot drop that without doing redeveloping in old JDK syntax.....

Please correct me if im tottaly wrong with my assumptions....开发者_C百科

If it isnt possiable to dynamicly send the Tomcat the JDK version how can i change the default JDK, I know its in $CATALINA_BASE/conf/web.xml but i dont know what need to be changed...

Thanks Upfront.


According to the Jasper documentation, the default source and target level for JSP compilation is determined by the JDK that Tomcat is using, and can be overriden using init parameters (described in the above page).

But I don't think this is going to help you.

From what I can make out, your Tomcat's JVM is 1.4.x, but you want to compile at source level 1.5 with the 1.5 class libraries. I believe that this cannot possibly work.

The Java compiler in JDK 1.4 is not capable of compiling Java 1.5 syntax. Furthermore, the class libraries in JDK 1.4 are (... wait for it ...) Java 1.4, not 1.5, so if your JSPs uses 1.5 classes or methods the generated Java would not compile. And even if you did manage to compile the JSPs / generated Java (e.g. with another JVM), you'd most likely see runtime problems loading the code on JDK 1.4.x.

AFAIK, if you want to use Java 1.5 features in your JSPs, you've no choice but to JDK 1.5 or later as your Tomcat's JVM.

And frankly, you should be upgrading to JDK 1.6 ASAP. JDK 1.4.x has been End-of-Lifed, and EOL for Java 1.5 can't be that far off. Besides, zillions of performance tweaks, bug fixes and new features have been added since 1.4.2.


Tomcat is just a java application. It is running under JVM. So, the JVM version is used does not depend on Tomcat but on java installed on your machine and JAVA_HOME environment variable defined.

So, do the following. First check which JDKs and JREs are installed on your machine. If you do not have special reasons to hold multiple java installation remove everything except the last one.

second, check your JAVA_HOME env. variable. It should point to the "correct" java installation.

Now run your tomcat and enjoy java 1.6 features including generics, enum and what else you want.

BTW, why are you using Tomcat 5.5? Move to at least tomcat 6, or, better Tomcat 7 that has cool new features.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜