Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get link Rhino to a web server?

52 views
Skip to first unread message

Geuis

unread,
Dec 22, 2008, 8:14:50 PM12/22/08
to
How can I connect Rhino and a web server, such as apache or lighttpd,
so that incoming web requests are handed from the server to Rhino to
run server-side JS scripts, then return the result to the server for
delivery to the browser?

I've got Rhino running via shell and have been having fun playing
around with it from the command line, but now I'd like to try my hand
at getting Rhino to act like an interpreter to interact with the
browser client.

Cormac Redmond

unread,
Dec 24, 2008, 10:23:54 AM12/24/08
to Geuis, dev-tech-js-...@lists.mozilla.org
Hi,

You say you have Rhino running via the shell. The next step for you would be
getting it running completely in a Java class.
Then, you could use a Servlet containter like tomcat. That will allow you
to, for example, run server-side Java code when a user clicks a button on a
webpage. This Java code will itself initialise Rhino and evaluate some
script, which will return a result to the Java code.

Setting this up is easy (but this is not the place to explain it). Have a
quick google for "tomcat jsp tutorial". Or even better "JSF tutorial".

Again, start off by getting Rhino up-and-running in a Java class. The Rhino
tutorials have dozens of simple examples.


Cheers,
Cormac

2008/12/23 Geuis <geuis...@gmail.com>

> _______________________________________________
> dev-tech-js-engine-rhino mailing list
> dev-tech-js-...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
>

Terry Braun

unread,
Dec 24, 2008, 10:55:31 AM12/24/08
to Cormac Redmond, Geuis, dev-tech-js-...@lists.mozilla.org
Hi,
Or if you are javascript centric, you can just write the web server in
javascript - which I am doing. Since I am an ex Java programmer my first
goal was to write a very basic java web server (no servlets) and then be
able to add javascript "processors" - such as a file processor to serve
directories etc. But as I have learned more about javascript I have
rewritten more and more of it in javascript. It is both a great way to
learn javascript and to have fun.
Terry


Cormac Redmond wrote:
> Hi,
>
> You say you have Rhino running via the shell. The next step for you would be
> getting it running completely in a Java class.
> Then, you could use a Servlet containter like tomcat. That will allow you
> to, for example, run server-side Java code when a user clicks a button on a
> webpage. This Java code will itself initialise Rhino and evaluate some
> script, which will return a result to the Java code.
>
> Setting this up is easy (but this is not the place to explain it). Have a
> quick google for "tomcat jsp tutorial". Or even better "JSF tutorial".
>
> Again, start off by getting Rhino up-and-running in a Java class. The Rhino
> tutorials have dozens of simple examples.
>
>
> Cheers,
> Cormac
>
> 2008/12/23 Geuis <geuis...@gmail.com>
>
>

Bret Lester

unread,
Dec 25, 2008, 12:35:35 AM12/25/08
to Geuis, dev-tech-js-...@lists.mozilla.org
Niche JSX

> _______________________________________________
> dev-tech-js-engine-rhino mailing list
> dev-tech-js-...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
>

--
Sent from Gmail for mobile | mobile.google.com

Bret Lester

unread,
Dec 25, 2008, 12:43:40 AM12/25/08
to Geuis, dev-tech-js-...@lists.mozilla.org
You may be interested in checking out Niche JSX
http://niche.bretlester.com/bundleinfo/niche-jsx/

I've been using Rhino for web scripting a lot lately. It is nice --
especially with XML literals (E4X)


On 12/22/08, Geuis <geuis...@gmail.com> wrote:

Maksim Lin

unread,
Dec 26, 2008, 7:10:19 PM12/26/08
to Geuis, dev-tech-js-...@lists.mozilla.org
Another good example of using rhino for web serving is helma: http://helma.org

Maks.

> _______________________________________________
> dev-tech-js-engine-rhino mailing list
> dev-tech-js-...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
>

--
Sent from my mobile device

Tom Robinson

unread,
Dec 27, 2008, 7:16:26 PM12/27/08
to

Throwing another option out there: FastCGI. It's is probably less than
ideal, but lots of web servers support FastCGI. Here's a "hello world"
app, a simple counter, using FastCGI's Java library:

importPackage(java.lang);
importPackage(Packages.com.fastcgi);

var count = 0;
while (new FCGIInterface().FCGIaccept() >= 0)
{
count++;
System.out.println("Content-type: text/html\n\n");
System.out.println("<html>");
System.out.println("<head><TITLE>FastCGI-Hello Java stdio</
TITLE></head>");
System.out.println("<body>");
System.out.println("<H3>FastCGI-HelloJava stdio</H3>");
System.out.println("request number " + count + " running on
host " + System.getProperty("SERVER_NAME"));
System.out.println("</body>");
System.out.println("</html>");
}

Requires the Java library from here: http://fastcgi.com/devkit/java/

I haven't been able to get mod_fastcgi to start instances
automatically, only manually by using the [apparently non-standard]
FCGI_PORT environment variable, and setting mod_fastcgi to use
localhost and the same port. Glancing at the library source, it seems
to decide to go into fcgi mode only if FCGI_PORT is set (otherwise it
goes into cgi mode; obviously not suitable for Rhino due to slow JVM
startup speed), so I think this library is outdated/incomplete/not
compatible with mod_fastcgi.

Does anyone know of a better Java FastCGI library? If not, would
anyone be interested in helping update it or write a new one for use
with Rhino?

Thanks.

Martin Blom

unread,
Jan 10, 2009, 12:49:05 PM1/10/09
to
Tom Robinson wrote:

> Requires the Java library from here: http://fastcgi.com/devkit/java/
>
> I haven't been able to get mod_fastcgi to start instances
> automatically, only manually by using the [apparently non-standard]
> FCGI_PORT environment variable, and setting mod_fastcgi to use
> localhost and the same port. Glancing at the library source, it seems
> to decide to go into fcgi mode only if FCGI_PORT is set (otherwise it
> goes into cgi mode; obviously not suitable for Rhino due to slow JVM
> startup speed), so I think this library is outdated/incomplete/not
> compatible with mod_fastcgi.
>
> Does anyone know of a better Java FastCGI library? If not, would
> anyone be interested in helping update it or write a new one for use
> with Rhino?

In ESXX (http://esxx.org/), I use a FastCGI library called JFast that I
found on the web a couple of years ago. I think it has disappeared since
then. It was licensed under a BSD license.

I've made it available via Subversion, including a few small bug fixes,
at http://svn.berlios.de/svnroot/repos/esxx/ext/jfast/ if anybody is
interested.

(It only supports FastCGI external mode, but that's what I prefer so I
don't mind.)

Kris Zyp

unread,
Jan 12, 2009, 10:01:55 AM1/12/09
to
Also, there are a number of JavaScript servers that provide a web
application server based on Rhino. Here is a list of some of them:
http://en.wikipedia.org/wiki/Server-side_JavaScript
(I am the lead of Persevere (http://www.persvr.org), which is one of
them).
Kris
0 new messages