Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #28585 > unrolled thread
| Started by | Jan Burse <janburse@fastmail.fm> |
|---|---|
| First post | 2014-05-28 23:49 +0200 |
| Last post | 2014-05-29 10:59 +0200 |
| Articles | 7 — 4 participants |
Back to article view | Back to comp.lang.java.programmer
JDK 1.8 Power not Available for the Web, Yes or No? Jan Burse <janburse@fastmail.fm> - 2014-05-28 23:49 +0200
Re: JDK 1.8 Power not Available for the Web, Yes or No? Arne Vajhøj <arne@vajhoej.dk> - 2014-05-28 18:15 -0400
Re: JDK 1.8 Power not Available for the Web, Yes or No? MilkoB <mbrbc111@cogeco.ca> - 2014-05-28 19:27 -0400
Re: JDK 1.8 Power not Available for the Web, Yes or No? Joerg Meier <joergmmeier@arcor.de> - 2014-05-29 01:03 +0200
Re: JDK 1.8 Power not Available for the Web, Yes or No? Jan Burse <janburse@fastmail.fm> - 2014-05-29 11:58 +0200
Re: JDK 1.8 Power not Available for the Web, Yes or No? Jan Burse <janburse@fastmail.fm> - 2014-05-29 10:50 +0200
Re: JDK 1.8 Power not Available for the Web, Yes or No? Jan Burse <janburse@fastmail.fm> - 2014-05-29 10:59 +0200
| From | Jan Burse <janburse@fastmail.fm> |
|---|---|
| Date | 2014-05-28 23:49 +0200 |
| Subject | JDK 1.8 Power not Available for the Web, Yes or No? |
| Message-ID | <lm5lkl$j95$1@news.albasani.net> |
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
closure.
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
[toc] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2014-05-28 18:15 -0400 |
| Message-ID | <53866001$0$303$14726298@news.sunsite.dk> |
| In reply to | #28585 |
On 5/28/2014 5:49 PM, Jan Burse wrote: > 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. > 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. 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 compiler. 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 exist. Arne
[toc] | [prev] | [next] | [standalone]
| From | MilkoB <mbrbc111@cogeco.ca> |
|---|---|
| Date | 2014-05-28 19:27 -0400 |
| Message-ID | <hhuhv.1115596$y81.951875@fx13.iad> |
| In reply to | #28587 |
On 05/28/2014 06:15 PM, Arne Vajhøj wrote:
> On 5/28/2014 5:49 PM, Jan Burse wrote:
>> 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.
>
>> 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.
>
> 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
> compiler.
>
> 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
> exist.
>
> Arne
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
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
<!-- Add the following new lines exactly here -->
<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>1.8</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.8</param-value>
</init-param>
<init-param>
<param-name>compiler</param-name>
<param-value>modern</param-value>
</init-param>
<!-- End of newly added lines -->
</servlet>
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,
MB
[toc] | [prev] | [next] | [standalone]
| From | Joerg Meier <joergmmeier@arcor.de> |
|---|---|
| Date | 2014-05-29 01:03 +0200 |
| Message-ID | <6v2fa58qprqb.9ad3qb3lzvbv.dlg@40tude.net> |
| In reply to | #28585 |
On Wed, 28 May 2014 23:49:09 +0200, Jan Burse wrote: > 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 > closure. 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 -- Ich lese meine Emails nicht, replies to Email bleiben also leider ungelesen.
[toc] | [prev] | [next] | [standalone]
| From | Jan Burse <janburse@fastmail.fm> |
|---|---|
| Date | 2014-05-29 11:58 +0200 |
| Message-ID | <lm70cl$q0c$1@news.albasani.net> |
| In reply to | #28588 |
Joerg Meier schrieb: > 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 > 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? http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files My guess: Its even more difficult to make taglibs work with local classes, than it is already with <% %> and out. The bets are open. Bye
[toc] | [prev] | [next] | [standalone]
| From | Jan Burse <janburse@fastmail.fm> |
|---|---|
| Date | 2014-05-29 10:50 +0200 |
| Message-ID | <lm6sda$hh5$1@news.albasani.net> |
| In reply to | #28585 |
Jan Burse schrieb:
> Comments welcome
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?
http://stackoverflow.com/questions/18208805/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
http://www.snippetit.com/2009/05/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.
Bye
[toc] | [prev] | [next] | [standalone]
| From | Jan Burse <janburse@fastmail.fm> |
|---|---|
| Date | 2014-05-29 10:59 +0200 |
| Message-ID | <lm6suc$ifk$1@news.albasani.net> |
| In reply to | #28594 |
Jan Burse schrieb: > > 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 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? http://stackoverflow.com/questions/1488412/what-scala-web-frameworks-are-available
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web