• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java 8 application server

 
Ranch Hand
Posts: 120
IntelliJ IDE Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomcat 8 apparently does not work with Java 8. So is any alternative available already ?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's not true, I'm using Tomcat 8 on Java 8 without problems. Why do you think Tomcat 8 does not work on Java 8?

From the Tomcat 8.0.15 Release Notes:

Tomcat 8.0.15 Release Notes wrote:
Tomcat 8.0 is designed to run on Java SE 7 and later.

 
Stan Sokolov
Ranch Hand
Posts: 120
IntelliJ IDE Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:That's not true, I'm using Tomcat 8 on Java 8 without problems. Why do you think Tomcat 8 does not work on Java 8?

From the Tomcat 8.0.15 Release Notes:

Tomcat 8.0.15 Release Notes wrote:
Tomcat 8.0 is designed to run on Java SE 7 and later.



It does not when it comes to JSP pages. Try to use closures in a JSP page



The exception will follow as bellow.


type Exception report

message Unable to compile class for JSP:

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 131 in the jsp file: /inventory.jsp
Lambda expressions are allowed only at source level 1.8 or above
128: }
129:
130:
131: Collections.sort(selectedLines, (String o1, String o2)->f.parse(o1.split(",")[0]).compareTo(f.parse(o2.split(",")[0])));
132:
133: //Collections.sort(selectedLines, new StringDateComparator());
134: DateFormat formatterCsv1 = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss SSS");


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:199)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:450)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

note The full stack trace of the root cause is available in the Apache Tomcat/8.0.15 logs.

 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can configure what Java compiler Tomcat should use for compiling JSPs. It should work if you configure it to use the JDK 8 compiler.

See Jasper 2 JSP Engine How To

There are settings named compiler, compilerSourceVM and compilerTargetVM. By default it's set to Java 7, but you can change that.
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Of course, just by coding complex logic like that in a JSP, you're likely to get a from our resident defenders of the MVC paradigm.


ASPs were bad enough. Writing JSPs like they were ASPs is generally not recommended.
 
Stan Sokolov
Ranch Hand
Posts: 120
IntelliJ IDE Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tnx! It worked and I agree this is a junk design pattern to embed such a code in a jsp. Was just playing.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic