aspose file tools*
The moose likes Tomcat and the fly likes Compiler error on new type of for loop in 1.5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Compiler error on new type of for loop in 1.5" Watch "Compiler error on new type of for loop in 1.5" New topic
Author

Compiler error on new type of for loop in 1.5

bryan nelson
Ranch Hand

Joined: Jun 16, 2003
Posts: 95
Hello everyone,

I've come across an error on a jsp page that is using the new type of for loop from JDK 1.5.

Here's the code:

<% for (Operation op : Operation.values() ) %>

and here's the error:
[ServletException in:/web/jsp/admin/role/roleModify.jsp] Unable to compile class for JSP An error occurred at line: 102 in the jsp file: /web/jsp/admin/role/roleModify.jsp Generated servlet error: Syntax error on token ":", ; expected An error occurred at line: 102 in the jsp

I have this same type of loop working in actual .java file; why won't it work here?

Do I have to import something into the .jsp so that I can use the new 1.5 syntax?

Any leads would be greatly appreciated!

Thanks,
bryan


"...and the Truth will set you free."
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Are you sure your app container is using 1.5?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
bryan nelson
Ranch Hand

Joined: Jun 16, 2003
Posts: 95
Yep. I'm using Tomcat 5.5.9.

And here's the JVM path that it's pointing to:

C:\Java\jre1.5.0_04\bin\client\jvm.dll


I'm confused. Is there some other setting in Tomcat that I could check?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61230
    
  66

Moved to the Tomcat forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
bryan nelson
Ranch Hand

Joined: Jun 16, 2003
Posts: 95
I've been moved! Nice!

So does anyone in here have any ideas?

Thanks so much!
b
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by bryan nelson:
I've been moved! Nice!

That's a good thing. You're in the right forum now.


One thing that I do know is that, starting with 5.5x, Tomcat ships with it's own compiler (JTD: the one from the folks at Eclipse). Not sure how much help that is but it might get you pointed in the right direction or open up some other other avenues to explore.

http://eclipse.sys-con.com/read/46259.htm?CFID=81489&CFTOKEN=E94B9749-1022-6501-84AB13AC36D334D1
bryan nelson
Ranch Hand

Joined: Jun 16, 2003
Posts: 95
Alright everyone...check it out:

Ben was indeed on the right track with his last post. Apparently (and feel free to correct me if any of this is wrong) Tomcat 5.5.9 comes with the jasper-compiler-jdt.jar...and apparently it doesn't parse any scriptlets written in 1.5 (yet, although it may in the future??). So the fix is to swap that file out with the newest ant.jar file. That's the first step.

The next step is making sure that tomcat is setup to actually recognize the 1.5 scriptlets. In your CATALINA\conf\web.xml file you need to add two entries:


that will make tomcat compile with 1.5 instead of 1.4...1.4 is the default according to the docs on the Tomcat 5.5.x Jasper Page.

And there it is. At least, that worked for us here. Of course another alternative is just to not use any scriptlets in your jsp anyway (which I personally think is better), but you do what you gotta do!

Hope this helps someone!

b
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Nice job Bryan,
Thanks for posting back with the work around.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Compiler error on new type of for loop in 1.5