On Dec 22, 5:14 pm, Geuis <[email protected]> wrote:
> 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.

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.
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to