tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Any tutorials or hints about JSP using javax.script engines instead of Java?
Date Fri, 11 Oct 2019 20:57:53 GMT
Hash: SHA256


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] [2]
> 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:

  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
Comment: Using GnuPG with Thunderbird -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message