You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Rony G. Flatscher (Apache)" <ro...@apache.org> on 2019/10/08 15:11:03 UTC

Any tutorials or hints about JSP using javax.script engines instead of Java?

Does anyone know of any tutorials that would demonstrate how to use any javax.script language in
JSPs instead of Java (e.g. using Jython or JavaScript instead)?

If not, any advice/hint how to realize/create such a functionality (for then creating such a
tutorial instead) would be highly appreciated!

---rony




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Any tutorials or hints about JSP using javax.script engines instead of Java?

Posted by "Rony G. Flatscher (Apache)" <ro...@apache.org>.
Hi Konstantin,

On 09.10.2019 15:31, Konstantin Kolinko wrote:
> вт, 8 окт. 2019 г. в 18:11, Rony G. Flatscher (Apache) <ro...@apache.org>:
>> Does anyone know of any tutorials that would demonstrate how to use any javax.script language in
>> JSPs instead of Java (e.g. using Jython or JavaScript instead)?
>>
>> If not, any advice/hint how to realize/create such a functionality (for then creating such a
>> tutorial instead) would be highly appreciated!
> 1. There is no such feature in Apache Tomcat.
>
> Tomcat implements JSP specification and the specification [1] only
> supports language="java" in a JSP declaration.
>
> [1] https://cwiki.apache.org/confluence/display/TOMCAT/Specifications#Specifications-JavaServerPagesandExpressionLanguageSpecifications
>
> Support for other language needs some specification document of such a
> feature, and I do not know about any such document.

Hmm, what steps would be necessary and where? One idea would be to extend the support for any of the
javax.script languages.

... cut ...

---rony



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Any tutorials or hints about JSP using javax.script engines instead of Java?

Posted by Konstantin Kolinko <kn...@gmail.com>.
вт, 8 окт. 2019 г. в 18:11, Rony G. Flatscher (Apache) <ro...@apache.org>:
>
> Does anyone know of any tutorials that would demonstrate how to use any javax.script language in
> JSPs instead of Java (e.g. using Jython or JavaScript instead)?
>
> If not, any advice/hint how to realize/create such a functionality (for then creating such a
> tutorial instead) would be highly appreciated!

1. There is no such feature in Apache Tomcat.

Tomcat implements JSP specification and the specification [1] only
supports language="java" in a JSP declaration.

[1] https://cwiki.apache.org/confluence/display/TOMCAT/Specifications#Specifications-JavaServerPagesandExpressionLanguageSpecifications

Support for other language needs some specification document of such a
feature, and I do not know about any such document.

2. Technically, support for JSPs is provided by "Jasper" component of
Tomcat and its org.apache.jasper.servlet.JspServlet

Technically, it should not rely on Tomcat internals and could be
swapped with some other implementation. (Not tested).

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Any tutorials or hints about JSP using javax.script engines instead of Java?

Posted by "Rony G. Flatscher (Apache)" <ro...@apache.org>.
George:

On 12.10.2019 02:17, George S. wrote:
> I'm a little confused. What would one hope to gain by doing this?

This way you gain all non-Java-programmers to use Tomcat and create server applications in their
programming languages of choice. Targeting javax.script languages any such language could be then
used, cf. [1].

It seems that it is still the case that PHP is predominately used for server pages.

In the case of Microsoft developed software cf. ASP.NET [2] which allows for using any of the .NET
languages [3], like VB.NET, C#, JScript.NET et.al.

So with other words, the idea is to make Apache Tomcat a friendly host for all those programmers who
do not program in Java, but rather in one of the JVM/javax.script languages, putting it again on par
with Microsoft's solution if not allowing for surpassing it! :)

---rony

[1] "List of JVM languages" (incomplete list): <https://en.wikipedia.org/wiki/List_of_JVM_languages>

[2] "ASP.NET": <https://en.wikipedia.org/wiki/ASP.NET>

[3] "List of CLI languages": <https://en.wikipedia.org/wiki/List_of_CLI_languages>


> On 10/8/2019 9:11 AM, Rony G. Flatscher (Apache) wrote:
>> Does anyone know of any tutorials that would demonstrate how to use any javax.script language in
>> JSPs instead of Java (e.g. using Jython or JavaScript instead)?
>>
>> If not, any advice/hint how to realize/create such a functionality (for then creating such a
>> tutorial instead) would be highly appreciated!
>>
>> ---rony


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Any tutorials or hints about JSP using javax.script engines instead of Java?

Posted by "André Warnier (tomcat)" <aw...@ice-sa.com>.
Hi.

On 12.10.2019 02:17, George S. wrote:
> I'm a little confused. What would one hope to gain by doing this?

I'm not that much of an expert on Tomcat or its "ecological niche", but in a general 
overall point of view, I would tend to say that anything that "opens up" tomcat to more 
programmers and more users cannot really be a bad thing.
As an example, maybe off-track : there are a lot of web applications based on ruby, 
python, javascript, perl, php, etc.. Mostly, they are based on development frameworks 
similar to the ones for JSP pages, only written in something else than java.  Porting 
these to tomcat using the CGI model is not really practical, and translating them to Java 
and JSP isn't either. (Apart from the fact that in order to really dominate java, you 
pretty much have to spend all your time on it.)
So if this "javax.script" would provide a shortcut to run, with minimal adaptations, pages 
written using some of these other languages, if only temporarily and as a prototype, why not ?

Of course there is a cost, and as Christopher previously pointed out, some previous 
attempt at this did not seem to have had many takers, and it pretty much seems to have 
died by lack of interest.
But then again, in terms of market coverage as a webserver, the cost for tomcat to be 
"single language centric", is certainly not null either.

>
> On 10/8/2019 9:11 AM, Rony G. Flatscher (Apache) wrote:
>> Does anyone know of any tutorials that would demonstrate how to use any javax.script
>> language in
>> JSPs instead of Java (e.g. using Jython or JavaScript instead)?
>>
>> If not, any advice/hint how to realize/create such a functionality (for then creating
>> such a
>> tutorial instead) would be highly appreciated!
>>
>> ---rony
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Any tutorials or hints about JSP using javax.script engines instead of Java?

Posted by "George S." <ge...@mhsoftware.com>.
I'm a little confused. What would one hope to gain by doing this?

On 10/8/2019 9:11 AM, Rony G. Flatscher (Apache) wrote:
> Does anyone know of any tutorials that would demonstrate how to use any javax.script language in
> JSPs instead of Java (e.g. using Jython or JavaScript instead)?
>
> If not, any advice/hint how to realize/create such a functionality (for then creating such a
> tutorial instead) would be highly appreciated!
>
> ---rony
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
-- 
George S.
*MH Software, Inc.*
Voice: 303 438 9585
http://www.mhsoftware.com

Re: Any tutorials or hints about JSP using javax.script engines instead of Java?

Posted by "Rony G. Flatscher (Apache)" <ro...@apache.org>.
Hi Chris,
> On 10/13/19 08:40, Rony G. Flatscher (Apache) wrote:
... cut ...
> > Or with other words, what is needed to allow "<%@page
> > language="rexx"%>" ("rexx" being a javax.script.Engine, could be
> > "javascript", "jython", "php", "jacl", "jlog", ...), which might
> > be the easiest for the script language programmers?
>
> I think your question *does* have an actual answer, but I'm going to
> put it off for one more post, because I think this is the better
> answer to your question: "It doesn't matter what is needed, because
> it's a bad idea and shouldn't be done, anyway."
>
> If you agree that better tag libraries are needed more than
> scripting-style code blocks, then why persist in trying to build-out
> technology to enable scripting-style code blocks?
>
> If I were king, I'd deprecate the "language" attribute in JSP and
> abolish scriptlets *entirely*, making this whole question moot.
>
> You can also resurrect the BSF-style tag library and allow any kind of
> scripting in there -- even mixed-language pages! -- that you want,
> which I also think is a bad idea.

Maybe an example makes clear what I would be after, using two JSP samples [1], [2] from the net that
serve as tutorials for JSPs being deployed via Tomcat:

  * [1] shows the following sample JSP page:
      o the code uses Java:

        <%@ page language="java" contentType="text/html"%>
        <%@ page import="java.text.*,java.util.*" %>
        <html>
        <head>
        <title>Date JSP</title>
        </head>
        <% SimpleDateFormat sdf=new SimpleDateFormat("MM/dd/yyyy"); %>
        <body>
        <h1>Welcome to Tomcat! Today is <%= sdf.format(new Date()) %></h1>
        </body>
        </html>

      o the above JSP should be replacable by e.g. using the RexxScriptEngine (implementing
        javax.script.ScriptEngine) hence with the following Rexx code [3] replacing the Java code above:

        <%@ page language="rexx" contentType="text/html"%>
        <html>
        <head>
        <title>Date JSP</title>
        </head>
        <body>
        <h1>Welcome to Tomcat! Today is <%= date("usa") %></h1>
        </body>
        </html>


  * [2] shows the following sample JSP page:
      o the code uses Java:

        <%@ page contentType="text/html;charset=UTF-8" language="java" %>
        <%@ page import="java.util.Date" %>
        <html>
        <head>
            <title>Hello World</title>
        </head>
        <body>
            <h1><% out.print("Hello World!"); %></h1>
            Today is: <% out.print(new Date().toString()); %>
        </body>
        </html>

      o the above JSP should be replacable by e.g. using the RexxScriptEngine (implementing
        javax.script.ScriptEngine) hence with the following Rexx code [3] replacing the Java code above:

        <%@ page contentType="text/html;charset=UTF-8" language="rexx" %>
        <html>
        <head>
            <title>Hello World</title>
        </head>
        <body>
            <h1><% out~print("Hello World!") %></h1>
            Today is: <% out~print(date()) %>
        </body>
        </html>

If the JSP samples [1], [2] are good for Java, than the suggested alternatives above (using Rexx for
the sake of the example) would be good for any other (Java scripting) language as well?

Such a solution would allow non-Java-programmers to create and deploy JSPs written in their language
of choice [4] using Tomcat without a need to know Java.

---rony

[1] "How to Run a JSP Program in Apache Tomcat (Windows)", URL:
<https://www.webucator.com/how-to/how-run-jsp-program-apache-tomcat-windows.cfm>

[2] "HelloWorld from Java jsp with OpenJDK 11 packaged Maven war and deploy on Tomcat 9", URL:
<https://github.com/jbilander/HowTos/wiki/HelloWorld-from-Java-jsp-with-OpenJDK-11-packaged-Maven-war-and-deploy-on-Tomcat-9>

[3] Here ooRexx ("open object Rexx") is being employed which is an interpreted, dynamically typed
and (like Smalltalk) message based language with a very easy syntax, yet quite powerful. The message
operator is the tilde (~), left is the receiver, right the message name with optional arguments
(conceptually the receiver looks up the method that has the same name as the received message,
invokes it and returns the result, if any). Here the built-in-function date() gets used to get and
display the current day.

[4] The idea would be to create a generic support by using javax.script such that all languages for
which javax.script.ScriptEngine implementations exist could be deployed by merely changing the
language attribute from "java" to the registered name of the scripting language one wishes to use.
Such a javax.script support would allow for supplying e.g. the request and response objects as
arguments for each invocation in a standardized way by placing them in the
ScriptContext.ENGINE_SCOPE Bindings using e.g. ScriptEngine.ARGV as a key (a constant resolving to
"javax.script.argv") for the Java array that contains the arguments, optionally adding "out" and the
like into the ScriptContext.ENGINE_SCOPE Bindings etc. (like submitting the name of the JSP file for
debugging via ScriptContext.FILENAME, ...)



Re: Any tutorials or hints about JSP using javax.script engines instead of Java?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Rony,

On 10/13/19 08:40, Rony G. Flatscher (Apache) wrote:
> Chris:
>
> thank you for your information and reflections!
>
>> On 10/10/19 08:16, Rony G. Flatscher (Apache) wrote:
>>
> ... cut ...
>>> Maybe if some standard "script" taglib library for
>>> javax.script languages existed like the proof-of-concept one in
>>> [1] then that could be exploited/(re)used rather than coming up
>>> with non-standard implementations of their own.
>>
>> I hesitate to say this due to your previous experience with tag
>> libraries, but ... a tag library is basically a JSP thing which
>> obviates the need to use any actual Java in the JSP file.
>>
>> (My statements here are basically already covered in the
>> publication; I'm re-itterating them, here for emphasis and
>> clarification.)
>>
>> There isn't anything inherently Java-esque about any of the
>> existing tag libraries (e.g. JSTL), and once you have converted a
>> page filled with spaghetti Java code in scriptlets (e.g. <% java
>> goes here %>) into one that exclusively uses tag libraries, the
>> implications of using <%@page language="java" instead of e.g.
>> language="jython" or whatever kind of evaporate.
>>
>> That is, if you write a tag library, then:
>>
>> 1. Using the taglib in the JSP file isn't using Java 2. Using the
>> taglib in the JSP isn't using the other language, either...
>> instead, it's using ... taglib-lang or whatever you want to call
>> that
>>
>> So if you want to do this:
>>
>> <%@page language="c" import="<stdio.h>" %> <% println("Hello,
>> world!\n"); %>
>>
>> Then you'd need to get a "language" binding in JSP.
>>
>> But instead, if you want to to this:
>>
>> <%@page language="doesntmatter"%> <mytaglib:say>Hello,
>> world!</mytaglib:say>
>
> How (where, what needs to be extended, what needs to be deployed
> how) would this have to be implemented to allow it to work
> generically in all containers for all javax.script engines?
>
>
>> Then you can implement the tag library using any programming
>> language you want, as long as you are able to register it
>> properly with the JSP servlet and have it respond to the calls
>> targeted at the tag library interface(s) you have implemented.
>>
>> IMHO, the BSF taglib is a project that deserved to die. It took
>> all of the horrible possibilities of Java scriptlets in JSPs and
>> made the language pluggable so that you could have garbage
>> spaghetti code in your language of choice packaged inside of a
>> JSP. Good riddance.
>>
>> Resurrecting the capabilities of the BSF taglib is, again IMHO,
>> a waste of effort. That effort would be better spent creating
>> better (or more diverse) tag libraries that don't expose the
>> concept of "scriptlets" to the programmer /at all/.
>
> Concurring! :)
>
> Actually in [1], p. 58, last paragraph ( almost ten years ago) the
> student concluded:
>
> "While the Script Tag Library fills a gap in current Java web
> development technology, more work could be done on the JSP
> specification itself. The specification already includes the page
> directive facility for specifying the language of a JSP page. Now
> that JSR-223 is part of the core Java library, it is possible to
> mandate that implementing containers should support languages other
> than Java by using the javax.script API. While this would prevent
> the mixing of multiple scripting languages on one page, it is
> unlikely that a JSP page would be worked on by multiple developers
> using different scripting languages, making that ability something
> of an edge case."
>
> What would be the starting point, how would you advise to implement
> this such that any javax.script language could be used just by
> denoting its name? (Short of such a possibility the
> "scriptlet"-concept can hardly be circumvented.)
>
> Or with other words, what is needed to allow "<%@page
> language="rexx"%>" ("rexx" being a javax.script.Engine, could be
> "javascript", "jython", "php", "jacl", "jlog", ...), which might
> be the easiest for the script language programmers?

I think your question *does* have an actual answer, but I'm going to
put it off for one more post, because I think this is the better
answer to your question: "It doesn't matter what is needed, because
it's a bad idea and shouldn't be done, anyway."

If you agree that better tag libraries are needed more than
scripting-style code blocks, then why persist in trying to build-out
technology to enable scripting-style code blocks?

If I were king, I'd deprecate the "language" attribute in JSP and
abolish scriptlets *entirely*, making this whole question moot.

You can also resurrect the BSF-style tag library and allow any kind of
scripting in there -- even mixed-language pages! -- that you want,
which I also think is a bad idea.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl2lv2wACgkQHPApP6U8
pFjH6A/+L+l/XMnnPOkXBBrHDHG6MFactMau8T/3aPefTpK+v1MuvYu5YUMpnYCb
hL1zZcs3jhOn2dxTkG1oP+G4wRF1hlfNdU4GQ2hQ6PjB02qFN7Mm1kur1d//E5kK
4ARB04AuA6pGCuW7L8JUhILpZq5mVrwvGV0HSbQy7lKx2eqaBMd5AxbO6IxLtj1p
gx3Zd5e+Ex70Susl7hhzUfr7AC4Vi5jk4EUYGaEYND719iPx3aU9gazomPNRVf3C
fXqHNVAqochuDF7Z4tQUsY87nOAqsg5XexGtliiKbYI6hQ/vWKitEF3P/X4AER1J
HneY87Snhghz2RW1n4Mou6jupMZ7kGf7dB5IQ3yHjCkVbjOPFpE+jjyV2TLSnoYU
v/lkFnSWQdPDHlRtzbFsD/4zicCtkfCYK2QRCnN1A8qtOXS06ek5dhuNybam0Lbz
civdG9LygwpwLkpxq3lNvTw9yOauF7LwV1yV/BvGwdD0m5HNoohveSESw6A4ZJT0
oLWiOLBq0OLuYBrtUXse+xcdmz5bMCjJ03ll8TuMF2dpowdeoK6+TrZFIEMyw6cb
Et75gASS89D8s6bqK7TlLad2O6+Zb6a2adUgOQuQys7ijwUunOKOGumh3V5eRRgH
t3iczwTYLFw+1NEagNzb1Dsl+TO1i4PBN5hhDp2sqeTCuCJeCdA=
=GUz4
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Any tutorials or hints about JSP using javax.script engines instead of Java?

Posted by "Rony G. Flatscher (Apache)" <ro...@apache.org>.
Chris:

thank you for your information and reflections!

> On 10/10/19 08:16, Rony G. Flatscher (Apache) wrote:
>
... cut ...
> > Maybe if some standard "script" taglib library for javax.script
> > languages existed like the proof-of-concept one in [1] then that
> > could be exploited/(re)used rather than coming up with non-standard
> > implementations of their own.
>
> I hesitate to say this due to your previous experience with tag
> libraries, but ... a tag library is basically a JSP thing which
> obviates the need to use any actual Java in the JSP file.
>
> (My statements here are basically already covered in the publication;
> I'm re-itterating them, here for emphasis and clarification.)
>
> There isn't anything inherently Java-esque about any of the existing
> tag libraries (e.g. JSTL), and once you have converted a page filled
> with spaghetti Java code in scriptlets (e.g. <% java goes here %>)
> into one that exclusively uses tag libraries, the implications of
> using <%@page language="java" instead of e.g. language="jython" or
> whatever kind of evaporate.
>
> That is, if you write a tag library, then:
>
> 1. Using the taglib in the JSP file isn't using Java
> 2. Using the taglib in the JSP isn't using the other language,
> either... instead, it's using ... taglib-lang or whatever you want to
> call that
>
> So if you want to do this:
>
> <%@page
>   language="c"
>   import="<stdio.h>"
> %>
> <%
>   println("Hello, world!\n");
> %>
>
> Then you'd need to get a "language" binding in JSP.
>
> But instead, if you want to to this:
>
> <%@page language="doesntmatter"%>
> <mytaglib:say>Hello, world!</mytaglib:say>

How (where, what needs to be extended, what needs to be deployed how) would this have to be
implemented to allow it to work generically in all containers for all javax.script engines?


> Then you can implement the tag library using any programming language
> you want, as long as you are able to register it properly with the JSP
> servlet and have it respond to the calls targeted at the tag library
> interface(s) you have implemented.
>
> IMHO, the BSF taglib is a project that deserved to die. It took all of
> the horrible possibilities of Java scriptlets in JSPs and made the
> language pluggable so that you could have garbage spaghetti code in
> your language of choice packaged inside of a JSP. Good riddance.
>
> Resurrecting the capabilities of the BSF taglib is, again IMHO, a
> waste of effort. That effort would be better spent creating better (or
> more diverse) tag libraries that don't expose the concept of
> "scriptlets" to the programmer /at all/.

Concurring! :)

Actually in [1], p. 58, last paragraph ( almost ten years ago) the student concluded:

    "While the Script Tag Library fills a gap in current Java web development technology, more work
    could be done on the JSP specification
    itself. The specification already includes the page directive facility for specifying the
    language of a JSP page. Now that JSR-223 is part of the
    core Java library, it is possible to mandate that implementing containers should support
    languages other than Java by using the javax.script
    API. While this would prevent the mixing of multiple scripting languages on one page, it is
    unlikely that a JSP page would be worked on by multiple developers using different scripting
    languages, making that ability something of an edge case."

What would be the starting point, how would you advise to implement this such that any javax.script
language could be used just by denoting its name?
(Short of such a possibility the "scriptlet"-concept can hardly be circumvented.)

Or with other words, what is needed to allow "<%@page language="rexx"%>" ("rexx" being a
javax.script.Engine, could be "javascript", "jython", "php", "jacl", "jlog", ...), which might be
the easiest for the script language programmers?

---rony

[1]  Ryabenkiy S.: "Java Web Scripting und Apache Tomcat",
<http://wi.wu.ac.at/rgf/diplomarbeiten/BakkStuff/2010/201007_Ryabenkiy/201007_Ryabenkiy_WebScripting_ApacheTomCat_TagLib.pdf>.




Re: Any tutorials or hints about JSP using javax.script engines instead of Java?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Rony,

On 10/10/19 08:16, Rony G. Flatscher (Apache) wrote:
> Hi Chris,
>
>> On 10/9/19 07:08, Rony G. Flatscher (Apache) wrote:
>>> On 08.10.2019 21:16, André Warnier (tomcat) wrote:
>>>> On 08.10.2019 17:11, Rony G. Flatscher (Apache) wrote:
>>>>> Does anyone know of any tutorials that would demonstrate
>>>>> how to use any javax.script language in JSPs instead of
>>>>> Java (e.g. using Jython or JavaScript instead)?
>
> ... cut ...
>
>> My own (particularly uninformed) opinion is that most scripting
>> languages that have wanted to get into JVMs/app servers have
>> simply built their own technologies to handle everything, so it
>> doesn't run through JSP itself.
>>
>> For example, Lucee[1] is a CFML implementation in Java, but it
>> doesn't (always) use JSP. They have a separate "interpreter" for
>> it instead of building huge tag libraries to fit it into JSP. (I
>> say "interpreted" because I don't know if they actually interpret
>> the files each time on demand, or if there is a compilation step
>> at some point. It doesn't really matter either way.)
>>
>> I haven't looked at it in depth, but I believe this is also what
>> Apache JGroovy[2] does.
>>
>> -chris
>>
>> [1] https://lucee.org/ [2] https://groovy-lang.org/
>
> Maybe if some standard "script" taglib library for javax.script
> languages existed like the proof-of-concept one in [1] then that
> could be exploited/(re)used rather than coming up with non-standard
> implementations of their own.

I hesitate to say this due to your previous experience with tag
libraries, but ... a tag library is basically a JSP thing which
obviates the need to use any actual Java in the JSP file.

(My statements here are basically already covered in the publication;
I'm re-itterating them, here for emphasis and clarification.)

There isn't anything inherently Java-esque about any of the existing
tag libraries (e.g. JSTL), and once you have converted a page filled
with spaghetti Java code in scriptlets (e.g. <% java goes here %>)
into one that exclusively uses tag libraries, the implications of
using <%@page language="java" instead of e.g. language="jython" or
whatever kind of evaporate.

That is, if you write a tag library, then:

1. Using the taglib in the JSP file isn't using Java
2. Using the taglib in the JSP isn't using the other language,
either... instead, it's using ... taglib-lang or whatever you want to
call that

So if you want to do this:

<%@page
  language="c"
  import="<stdio.h>"
%>
<%
  println("Hello, world!\n");
%>

Then you'd need to get a "language" binding in JSP.

But instead, if you want to to this:

<%@page language="doesntmatter"%>
<mytaglib:say>Hello, world!</mytaglib:say>

Then you can implement the tag library using any programming language
you want, as long as you are able to register it properly with the JSP
servlet and have it respond to the calls targeted at the tag library
interface(s) you have implemented.

IMHO, the BSF taglib is a project that deserved to die. It took all of
the horrible possibilities of Java scriptlets in JSPs and made the
language pluggable so that you could have garbage spaghetti code in
your language of choice packaged inside of a JSP. Good riddance.

Resurrecting the capabilities of the BSF taglib is, again IMHO, a
waste of effort. That effort would be better spent creating better (or
more diverse) tag libraries that don't expose the concept of
"scriptlets" to the programmer /at all/.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl2g7NEACgkQHPApP6U8
pFgNGA/8CFNKcfIOzf52FC2Nu0/LfC0TQ36+mSazkLloMkqXCBhI85yKXw55Mz94
fdLXFqN1mX0ZXnUgAXmer3MPBBdNceENjv8AjkhHKqXFUOTboXbg2/2XpYguddne
itM5XKHqhq4k8uG9wXnrgAOhrNTAOtaRKOaq4Lg9USinhdfVUrn+3OCyn8+eydzs
k096HMao/Li221y9vAoc+1iJPM3qWthgQA6GTrvdWIsqBiP0WOTT0XO6ifzDf5SX
0UmfYr7E6m5vAFBG0vieqjgA9U6OgOX59Dzc3a0XSF7ifWdmQbMntU6Rbaw7yIPb
gBdChMZeVIE89IlM3WY8jBcEjlK0FZVGjcEnPbCIQ8xdJscFpeK4Pn5vlCiXtWwM
2RcioHKSRu9OKpWN+uz7WqvNIwkbMyd1S+AKbqJxd2k2UN5yn2bKNc6SKIW4hJ9w
Srz1UE2yR/rAXlvNgtZy6gJSOE7mh+YtsrrawIUGXUOazOKkwTip6dve7xVLhLEm
RVgMlu4YOK6rMzDL8kydaNNKSw8csCuNyEpFjhwW+aKvUY3qhziRcGEF25rtkRaw
6WcnAl2sMPqcZJKLxzOQezgkzfPfJsUWMIYihtec65lV7XtKQJvCSOLLXBU272aa
yCp158Mqlkukt7Yi3kxHgCuCFaeYdi9JZrsdguAhyyOV8OISy+w=
=6QJV
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Any tutorials or hints about JSP using javax.script engines instead of Java?

Posted by "Rony G. Flatscher (Apache)" <ro...@apache.org>.
Hi Chris,

> On 10/9/19 07:08, Rony G. Flatscher (Apache) wrote:
> > On 08.10.2019 21:16, André Warnier (tomcat) wrote:
> >> On 08.10.2019 17:11, Rony G. Flatscher (Apache) wrote:
> >>> Does anyone know of any tutorials that would demonstrate how to
> >>> use any javax.script language in JSPs instead of Java (e.g.
> >>> using Jython or JavaScript instead)?

... cut ...

> My own (particularly uninformed) opinion is that most scripting
> languages that have wanted to get into JVMs/app servers have simply
> built their own technologies to handle everything, so it doesn't run
> through JSP itself.
>
> For example, Lucee[1] is a CFML implementation in Java, but it doesn't
> (always) use JSP. They have a separate "interpreter" for it instead of
> building huge tag libraries to fit it into JSP. (I say "interpreted"
> because I don't know if they actually interpret the files each time on
> demand, or if there is a compilation step at some point. It doesn't
> really matter either way.)
>
> I haven't looked at it in depth, but I believe this is also what
> Apache JGroovy[2] does.
>
> -chris
>
> [1] https://lucee.org/
> [2] https://groovy-lang.org/

Maybe if some standard "script" taglib library for javax.script languages existed like the
proof-of-concept one in [1] then that could be exploited/(re)used rather than coming up with
non-standard implementations of their own.

---rony

[1]
<wi.wu.ac.at/rgf/diplomarbeiten/BakkStuff/2010/201007_Ryabenkiy/201007_Ryabenkiy_WebScripting_ApacheTomCat_TagLib.pdf>
with an example that instrumentaes PHP and Rexx.




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Any tutorials or hints about JSP using javax.script engines instead of Java?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Rony,

On 10/9/19 07:08, Rony G. Flatscher (Apache) wrote:
> On 08.10.2019 21:16, André Warnier (tomcat) wrote:
>> On 08.10.2019 17:11, Rony G. Flatscher (Apache) wrote:
>>> Does anyone know of any tutorials that would demonstrate how to
>>> use any javax.script language in JSPs instead of Java (e.g.
>>> using Jython or JavaScript instead)?
>>>
>>> If not, any advice/hint how to realize/create such a
>>> functionality (for then creating such a tutorial instead) would
>>> be highly appreciated!
>>>
>>
>> I know nothing about the subject matter, but was searching Google
>> for "javax.script language jsp" and found this :
>> http://wi.wu.ac.at:8002/rgf/diplomarbeiten/BakkStuff/2010/201007_Ryab
enkiy/201007_Ryabenkiy_WebScripting_ApacheTomCat_TagLib.pdf
>>
>>
>>
(look around page 50).
>> Does this help ?
>
> Yes and no! :)
>
> This work has been created under my supervision almost ten years
> ago. :)
>
> The student did an exceptional job and created proof-of-concept
> taglibs for BSF (Apache Bean Scripting Framework) and JSR223 (Java
> scripting framework 'javax.script') (and even a proof-of-concept
> javax.script implementation for ooRexx).
>
>> On the side, even though (or maybe because) I did not previously
>> know anything about this, I found this document really impressive
>> in terms of providing a terse but extremely readable background
>> of the whole thing, all the way to some practical examples, all
>> in less than 100 pages. And this was a bachelor's thesis. So I
>> don't know if it helps you, but I enjoyed it.
> *Great!* :)
>> Looking up the author in Google, it doesn't seem that he really
>> needs my modest plaudits though.
>
> :)
>
> ---
>
> Maybe I should reformulate the request in form of open questions:
>
> * Is there any container that supports for the page directive the
> use of any javax.script language such as Jython, ooRexx, et.al.? *
> Is there any official/supported taglib to allow javax.script
> languages to be deployed in JSPs like demonstrated as a
> proof-of-concept in Stanislav Ryabenkiy's work? Are there any
> initiatives for creating such a support? * Is there any interest in
> allowing Java scripting languages to be used in JSPs as
> demonstrated as a proof-of-concept in Ryabenkiy's work with
> PHP/Quercus, Python/Jython and ooRexx?
>
> ---rony
>
> P.S.: My request stems from the expectation that by now
> javax.script languages are fully supported in JSPs, which may not
> be the case at all judging from the answers so far.
>
> P.P.S.: <http://wi.wu.ac.at/rgf/diplomarbeiten/> would list all
> sorts of student's work that might be interesting or of help for
> others (like the above mentioned Bachelor thesis).

My own (particularly uninformed) opinion is that most scripting
languages that have wanted to get into JVMs/app servers have simply
built their own technologies to handle everything, so it doesn't run
through JSP itself.

For example, Lucee[1] is a CFML implementation in Java, but it doesn't
(always) use JSP. They have a separate "interpreter" for it instead of
building huge tag libraries to fit it into JSP. (I say "interpreted"
because I don't know if they actually interpret the files each time on
demand, or if there is a compilation step at some point. It doesn't
really matter either way.)

I haven't looked at it in depth, but I believe this is also what
Apache JGroovy[2] does.

- -chris

[1] https://lucee.org/
[2] https://groovy-lang.org/
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl2ePvcACgkQHPApP6U8
pFjuVw//YHtKewJlqmJWTG4raTCOyXMCJLpCcdrkfkWADXsNncVgdY6vPn0csy0d
7eFYLC9oo6XqnLPJDmHZusRiFCcCTNaQTqJts1tvwWnTi79+eR8tupyWCfD9UQGR
Ozkil81G1ABtv81ILGbMjiiXVWgiXZERE7i7PMhrR++zR/T1CiC/FTA3q+kDsTtd
6lKzrsXmjoovDts69czovZulO4jMz7A53Ejs8L3Cubx+CO7UIRyH21pEY9CkvfgW
DhBjpiSiVNuixoMLHLQakuarxvSFY7+u7s9kollu4JbLalplDc4wgZx7DEn6SGzo
i0QZsGPnybkKHMnTUDTOuFozPFYkCuWccJ+SiP+VaEv6B5IlPg53Kq5SfvpcAS5l
Tslu/a9yI27AXCmawkD8uX7cFk/B0hK3QBHAWfu4WbvGEvZZjg5QQY4ztHNL4KyC
eBBayPpw0z6hf/sP28YjCEPt4s/Z1tqY1UDFKn3zcbiou8j85PsKmwcdC3tpwkLE
q3zqTcGStAU9lp41cnT4XXohnjJ0UKFae6ZE+f/TIDbkusc+ToKFEw2Xo3VbImBN
3Qvi1CHIfPMYMzgYBsmddfnWlJwZcfyfhvSXuajI5ogqeZfRJ7aa/HvU101Irzek
BEu6A/FZG6woIlkRJ4wVrtddyds1MpCWq31F7XG7WiTzzV8pFH8=
=i23J
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Any tutorials or hints about JSP using javax.script engines instead of Java?

Posted by "Rony G. Flatscher (Apache)" <ro...@apache.org>.
On 08.10.2019 21:16, André Warnier (tomcat) wrote:
> On 08.10.2019 17:11, Rony G. Flatscher (Apache) wrote:
>> Does anyone know of any tutorials that would demonstrate how to use any javax.script language in
>> JSPs instead of Java (e.g. using Jython or JavaScript instead)?
>>
>> If not, any advice/hint how to realize/create such a functionality (for then creating such a
>> tutorial instead) would be highly appreciated!
>>
>
> I know nothing about the subject matter, but was searching Google for "javax.script language jsp"
> and found this :
> http://wi.wu.ac.at:8002/rgf/diplomarbeiten/BakkStuff/2010/201007_Ryabenkiy/201007_Ryabenkiy_WebScripting_ApacheTomCat_TagLib.pdf
>
> (look around page 50).
> Does this help ?

Yes and no! :)

This work has been created under my supervision almost ten years ago. :)

The student did an exceptional job and created proof-of-concept taglibs for BSF (Apache Bean
Scripting Framework) and JSR223 (Java scripting framework 'javax.script') (and even a
proof-of-concept javax.script implementation for ooRexx).

> On the side, even though (or maybe because) I did not previously know anything about this, I found
> this document really impressive in terms of providing a terse but extremely readable background of
> the whole thing, all the way to some practical examples, all in less than 100 pages. And this was
> a bachelor's thesis. So I don't know if it helps you, but I enjoyed it.
*Great!*
:)
> Looking up the author in Google, it doesn't seem that he really needs my modest plaudits though.

:)

---

Maybe I should reformulate the request in form of open questions:

  * Is there any container that supports for the page directive the use of any javax.script language
    such as Jython, ooRexx, et.al.?
  * Is there any official/supported taglib to allow javax.script languages to be deployed in JSPs
    like demonstrated as a proof-of-concept in Stanislav Ryabenkiy's work? Are there any initiatives
    for creating such a support?
  * Is there any interest in allowing Java scripting languages to be used in JSPs as demonstrated as
    a proof-of-concept in Ryabenkiy's work with PHP/Quercus, Python/Jython and ooRexx?

---rony

P.S.: My request stems from the expectation that by now javax.script languages are fully supported
in JSPs, which may not be the case at all judging from the answers so far.

P.P.S.: <http://wi.wu.ac.at/rgf/diplomarbeiten/> would list all sorts of student's work that might
be interesting or of help for others (like the above mentioned Bachelor thesis).


Re: Any tutorials or hints about JSP using javax.script engines instead of Java?

Posted by "André Warnier (tomcat)" <aw...@ice-sa.com>.
On 08.10.2019 17:11, Rony G. Flatscher (Apache) wrote:
> Does anyone know of any tutorials that would demonstrate how to use any javax.script language in
> JSPs instead of Java (e.g. using Jython or JavaScript instead)?
>
> If not, any advice/hint how to realize/create such a functionality (for then creating such a
> tutorial instead) would be highly appreciated!
>

I know nothing about the subject matter, but was searching Google for "javax.script 
language jsp" and found this :
http://wi.wu.ac.at:8002/rgf/diplomarbeiten/BakkStuff/2010/201007_Ryabenkiy/201007_Ryabenkiy_WebScripting_ApacheTomCat_TagLib.pdf
(look around page 50).
Does this help ?

On the side, even though (or maybe because) I did not previously know anything about this, 
I found this document really impressive in terms of providing a terse but extremely 
readable background of the whole thing, all the way to some practical examples, all in 
less than 100 pages. And this was a bachelor's thesis. So I don't know if it helps you, 
but I enjoyed it.
Looking up the author in Google, it doesn't seem that he really needs my modest plaudits 
though.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Any tutorials or hints about JSP using javax.script engines instead of Java?

Posted by "Rony G. Flatscher (Apache)" <ro...@apache.org>.
On 08.10.2019 17:53, Zero wrote:
> On 10/8/19 5:11 PM, Rony G. Flatscher (Apache) wrote:
>> Does anyone know of any tutorials that would demonstrate how to use any javax.script language in
>> JSPs instead of Java (e.g. using Jython or JavaScript instead)?
>>
>> If not, any advice/hint how to realize/create such a functionality (for then creating such a
>> tutorial instead) would be highly appreciated!
>>
>> ---rony
>
>
> How about TutorialsPoint ?

Thank you, already went through that but did not find anything related to javax.script languages (it
documents the "language" attribute (giving "java" as a value) in the page directive
(https://www.tutorialspoint.com/jsp/page_directive.htm).

---rony


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Any tutorials or hints about JSP using javax.script engines instead of Java?

Posted by Zero <hz...@gmail.com>.
On 10/8/19 5:11 PM, Rony G. Flatscher (Apache) wrote:
> Does anyone know of any tutorials that would demonstrate how to use any javax.script language in
> JSPs instead of Java (e.g. using Jython or JavaScript instead)?
>
> If not, any advice/hint how to realize/create such a functionality (for then creating such a
> tutorial instead) would be highly appreciated!
>
> ---rony


How about TutorialsPoint ?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org