JDK 1.8 Power not Available for the Web, Yes or No?

Discussion in 'Java' started by Jan Burse, May 28, 2014.

  1. Jan Burse

    Jan Burse Guest

    Dear All,

    I made a small experiment recently with JSP
    and got the impression that the full power
    of the JDK 1.8 is currently not available for
    the web.

    What I tried was very simple, I included
    a closure in a JSP text. But the JSP system
    refused to allow the <% %> tags inside the

    My code looked as follows:

    do some computation;

    do some computation that

    needs a continuation (new some base class() {

    the computation of the continuation goes here

    %>here goes some HTML code of the continuation<%

    more computation of the continuation goes here

    do some other computation

    The problem I were facing were:

    - Tomcat refused an inner class without <% %>,
    in case I was addressing out in the inner class.
    It said that out is not final.

    - My IDE refused an inner class with <% %>
    all together, it marked it as an error.

    So it seems that all this fuzz about closures
    doesn't carry over to the web. Which makes me
    currious about some of the web frameworks from
    some of the functional languages camps.

    But I might also be totally wrong, i.e. that
    I don't have the right tomcat version etc..
    and that the web can profit from JDK 1.8. But
    I didn't find much through googling so far.

    Comments welcome
    Jan Burse, May 28, 2014
    1. Advertisements

  2. A given version of Tomcat uses a given version of a
    Java compiler.

    If your version of Tomcat does not use a Java compiler
    that supports Java 1.8 then it is obviously a no go.

    I am sure that eventually Tomcat will ship with a 1.8

    If you can't wait then use Google to find the description
    of how to change the version of ECJ that Tomcat uses (all
    recent Tomcat versions uses the Eclipse compiler not the
    regular SUN/Oracle JDK compiler). An 1.8 compatible ECJ do

    Arne Vajhøj, May 28, 2014
    1. Advertisements

  3. Jan Burse

    Joerg Meier Guest

    In addition to what Arne said, <% %> is hardly the only version of Java
    "for the Web", in fact, as far as I understand, it's a rather archaic,
    outdated and heavily discouraged nieche of Java Web.

    Liebe Gruesse,
    Joerg Meier, May 29, 2014
  4. Jan Burse

    MilkoB Guest

    The original poster needs to install Tomcat 8 and configure it to use
    JDK 1.8/J2EE 7.

    Then, open the Tomcat 8's $CATALINA_HOME/conf/web.xml in an editor, find
    the following section at around line 230 in the web.xml, add the lines
    between the two comments below


    <!-- Add the following new lines exactly here -->
    <!-- End of newly added lines -->

    and restart Tomcat. That should make Tomcat 8 start using javac
    from the Oracle/Sun JDK 8 instead of built-in ECJ.

    Hope this helps,

    MilkoB, May 29, 2014
  5. Jan Burse

    Jan Burse Guest

    Assume I configure tomcat to use JDK 1.8, and
    it will run with JDK 1.8, there are still
    problems with continuation.

    If I remember well some weeks ago, I tryed
    JDK 1.8 for tomcat, and it didn't work. And
    it seems that tomcat primarily goes for JDK 1.7,
    see also:

    Does Tomcat 8 support Java 8?

    But the issue is not whether I can plug-in
    a JDK 1.7 or JDK 1.8 into tomcat. The issue
    is whether JSP spec supports inner classes
    to a certain degree, so that some java features
    can be used.

    I don't know whether in tomcat 8 they changed
    the variable out to final, if this is at at
    all possible. So that I would be able to use
    it in an inner class.

    When I can use out in an inner class, then
    I will probably also be able to use it in the
    JDK 1.8 lambda notation.

    Inner classes are already a feature from the
    beginning of JDK 1.1. But I never checked how
    their support in JSP is. One finds the following
    article about inner classes and JSP:

    JSP: How to Declare Methods and Inner Class in JSP


    But the example above doesn't show the case of an
    inner annonymous class which is local to a method.
    I don't know whether local classes were also already
    introduced with JDK 1.1. But according to some
    sources the local classes came with nested classes
    in JDK 1.1 together with a greater application area
    for the final modifier:

    In Java 1.0, only fields, methods, and classes can be declared
    final. The addition of local classes in Java 1.1 has required a
    liberalization in the use of the final modifier. It can now be applied
    to local variables, method parameters, and even the exception parameter
    of a catch statement. The meaning of the final modifier remains the same
    in these new uses: once the local variable or parameter has been
    assigned a value, that value cannot be changed.

    But I really feel ashamed that I never checked before
    whether JSP can use local classes. My testing so
    far shows that this JDK 1.1 doesn't work, and subsequently
    I guess JDK 1.8 lambdas will also not work. Except
    if there isn't only a new tomcat 8, but also a new
    JSP spec.

    It is really driving me towards the functional
    programming camp, and trying some of the fancy
    functional web solutions. Including some Scala
    web frameworks. Since I have a couple of programming
    cases that could profit from JSP continuations.

    Jan Burse, May 29, 2014
  6. Jan Burse

    Jan Burse Guest

    It could be that continuations would break some
    of the assumptions of JSP. For example it could
    be that JSP assumes that out is only served by
    one thread as long as the servlet is alive. But
    I am not sure.

    With continuations I could easily let the servlet
    do some concurrent work. If the method that uses
    the continuation spawns threads. On the other I
    can also pick out manually and give it to threads.
    So that the problem is not tied to inner classes
    per se.

    BTW: Quite a number of Scala based frameworks:

    What Scala web-frameworks are available?
    Jan Burse, May 29, 2014
  7. Jan Burse

    Jan Burse Guest

    Well then here is the bonus question for those
    who don't like the <% %> or directly using the
    out variable in the JSP. Is there some taglib etc..
    that works with continuations?


    My guess: Its even more difficult to make taglibs
    work with local classes, than it is already with
    <% %> and out. The bets are open.

    Jan Burse, May 29, 2014
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.