Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat JSPs and JRE 5.0

 
Todd Johnson
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry if this is a stupid question, but I just started learning java about a month ago.

My development environment is J2SE 5.0 and Tomcat 5.5.9. When I'm writing servlets, or any other classes that I directly compile myself I can use the new J2SE 5.0 features (the collection based for loop, generic classes, etc). In fact in the case of collections I get warnings if I don't use the generics.

However when I write a JSP, if I try to use the 5.0 features such as the collection based for loop or the generics class types, tomcat won't compile the JSP. Am I doing something wrong, or do I am I forced to use 1.4 features only in JSPs?

Thanks in advance!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this is Tomcat-specific, I've moved it to the Tomcat forum.
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Apache Tomcat documentation -


The Java compiler from Eclipse JDT in included as the default compiler. It is an advanced Java compiler which will load all dependencies from the Tomcat class loader, which will help tremendously when compiling on large installations with tens of JARs. On fast servers, this will allow sub-second recompilation cycles for even large JSP pages. This new compiler will be updated to support the Java 5 syntax as soon as possible.


It should be possible to configure Tomcat to use the Sun JDK compiler. Or you can switch to an earlier stable Tomcat version (I think 5.0.28).

HTH
 
Dave Salter
Ranch Hand
Posts: 293
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, Tomcat doesn't use the JDK that you have installed, it uses its "internal" compiler.

There's an articlehere that explains how you can configure Tomcat to use the JDK to compile JSPs so you can then use 1.5 features in them.

Cheers,

Dave.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic