On Wed, Feb 17, 2021 at 8:59 AM Christopher Schultz <ch...@christopherschultz.net> 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. > > Usually if you want to use server-side JavaScript, you use something > like Node.js instead of a servlet container. Why not use Node? > > 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.
I found one example: - https://stackoverflow.com/questions/27710407/reuse-nashorn-scriptengine-in-servlet As a servlet implementation may embed a Jython engine to execute a python script, it will end up embedding a JS engine in a servlet to execute a .js like the example. I guess JS engine in Java vs. Node.js depends on whether or not you need to allow the .js scripts to use any existing Java libraries in the same JVM. Regards, Woonsan > > -chris > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org