Rony,

On 2/18/21 09:26, Rony G. Flatscher (Apache) wrote:
Hi Chris,

On 17.02.2021 14:59, Christopher Schultz wrote:
Rony and Leo,

On 2/17/21 02:58, Rony G. Flatscher (Apache) wrote:
Hi Leo,

why would you want to do that if you could do the same with Java? What is the 
motivation, the use
case for you?

How urgent is this (I may have something for both, Java EE and Jakarta EE, but 
need a little bit of
time)?

—-rony



On 15.02.2021 07:29, leo wrote:
Hi there

I am trying to find out how to process servlets written in server-side 
JavaScript through Tomcat.

I looked through the Tomcat FAQ and How-To but couldn't find anything. By 
googling I found a way
to hook up Python through Jython's PyServlet class. I tried this and it works 
great.

But I am looking for server-side JavaScript in Tomcat. I am aware of the 
JavaScript engine
Nashorn. Is there a way to hook up Nashorn with a servlet class, so that Tomcat 
serves JavaScript
servlets? Something like a "JavaScript Server Page" for Tomcat would be fine 
too.

Many thanks for any pointers,
Leo

ps: I use Tomcat 8.5, but I could move to another Tomcat version for this.

Weird; I never saw the OP on the list, only Rony's reply.

Yes, somehow it appeared later (Tuesday evening here, but the date and time in 
the post is Monday),
at least I recognized it Tuesday evening for the first time.


Usually if you want to use server-side JavaScript, you use something like 
Node.js instead of a
servlet container. Why not use Node?

This may be an option if you desire to write in JavaScript.
(But it may be the case that creating web applications under e.g. Tomcat may be 
even easier than
with Node, one would have to check it out though. ;) )


If you'd really like to use Tomcat, you will need to write a Servlet that 
establishes a JavaScript
environment (e.g. Nashhorn), provides all the plumbing for the 
servlet-container provided
resources (e.g. request, response, streams, session, etc.) as well as 
error-handling, etc.

It's a big job.

I'd be surprised is nobody had built something like this before. Or maybe 
everybody just uses
Node.js.

Well, I had a need to let Business Administration (BA) students who just 
learned programming in an
easy to learn, yet powerful programming language (ooRexx, a message based, 
dynamically typed
language, originating at IBM, but in open-source for a long time) create little 
web applications
with Tomcat. This way they experience what is basically involved when creating 
a web app in person
(even if they never will create fully fledged web apps on their own it will 
help them get a basic
understanding, better estimates for web app projects and the like).

For these BA students - even if they "experienced" - Java or JavaScript would 
be outside of their
scope, short of having enough learning and training time needed for mastering 
Java and JavaScript to
the extent that is needed to create fully-fledged web applications in Java 
(like a web-shop with
cart, e-mail-newsletter, uploading files, etc.). This has to do with the BA 
curriculum in question
that does not provide enough resources/time (in this particular case a four 
hours lecture with
homework assignments for the duration of one semester, i.e. appr. for four 
months) for learning a
programming language like Java or JavaScript to a professional extent, which 
would be possible e.g.
at a technical university or in specific IS/CIS studies.

My BA students on the other hand have a working knowledge and expierence with 
ooRexx (which they
learned in a four hour class during a semester and learned to apply it to 
interact with Windows, MS
Office, but also with Java - camouflaged as ooRexx - in an operating-system 
independent manner, i.e.
creating GUI, socket programs, OpenOffice/LibreOffice, exploiting JavaFX in an 
operating system
platform independent manner) such that ooRexx would have become feasible for 
them for using it to
learn and to experiment with creating  web apps, if they so desire. If only 
Tomcat et.al. would
allow for that somehow.

As having authored Apache BSF and JSR-223 (package javax.script introduced in 
Java 6) bindings for
ooRexx (using a combination of JNI, C++, Java, ooRexx) it would be feasible and 
desirable to create
a solution that not only supports a single scripting/programming language like 
ooRexx in this case,
but supports in general also any other programming language for which there is 
a bindings either for
Apache BSF and/or JSR-223 out of the box. As there is a JSR-223 bindings for 
Nashorn, one should be
able to apply Nashorn/JavaScript with this very same infrastructure.

Currently I am assessing the results (have yet to check-out and to grade two 
seminar papers and one
Bachelor thesis) and at first sight look quite promising, but this will take a 
little bit of time
until I get to them (planned for the end of next week), unless Leo has an 
urgent need. [In the
meantime, if there is interest, I could point to a little informal overview 
article where I
explained how one would create web apps in Java on Tomcat in general to the 
Rexx community and how
one would go about doing the same with deploying ooRexx web apps on Tomcat. 
Maybe this might be
helpful if you know of persons who are not coding or maybe not proficient 
enough in Java, but
like/are able to code in other programming/scripting languages and wish to 
create web apps in their
language of choice that get deployed with Tomcat.]

A BSF / JSR-233 environment that is available for any servlet container would certainly be an accomplishment, and probably very useful for some shops (and students!).

I wonder if there is anything we can learn / steal from Apache Sling.

-chris

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

Reply via email to