qexo-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qexo-general] XQuery as CGI scripts


From: Per Bothner
Subject: Re: [Qexo-general] XQuery as CGI scripts
Date: Sat, 21 Feb 2004 15:48:08 -0800
User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.6) Gecko/20040113

Jun Yu wrote:

Hello everybody,
I have a few questions about "Installing XQuery as CGI scripts".

1. In the description "Installing Kawa programs as CGI scripts", there are
such steps:
(1)kawa --servlet --xquery -C hello.xql
(2)cp hello*.class /var/www/cgi-bin/
(3)find the cgi-servlet program that Kawa builds and installs.
(4)Copy this program into the same CGI directory:
     cp /usr/local/bin/cgi-servlet /var/www/cgi-bin/
(5)Run the Kawa program: http://localhost/cgi-bin/hello

my question is:
(1)The step(1) will get a group of class files like hello*.class , not
only a single hello.class ?

Yes - because occasionally the Kawa compiler will create more than
just hello.class, but may also create some extra helper classes.

(2)Normally Java class files have to be executed through Java interpreter.
Why do not need it?

It does - cgi-server program invokes a Java VM.  See the source code
in bin/cgi-servlet.c.

The cgi-servlet program is Kawa's supplied
CGI-to-servlet bridge ? Does it function as Java interpreter?

It invokes a JVM.

(3)Usually, executing a CGI program, we should use
"http://localhost/cgi-bin/hello.class";, but step(5) use
"http://localhost/cgi-bin/hello"; ?

Step (4) is a typo.  It should be:

cp /usr/local/bin/cgi-servlet /var/www/cgi-bin/hello

(You can instead create a link, if you have multiple scripts.)
So 'hello' is the CGI executable.  The Web server runs the
hello program, which is really just the cgi-servet program,
but which get the name it was invoked under and uses that
as the name of the servlet class.

2. Comparing "Running XQuery as CGI scripts" with "Running XQuery as
servlet".
It says, the former "may take a few seconds to get the reply, mainly
because of the start-up time of the Java VM. That is why servlets are 
preferred."
I have some thought, but I am not sure if it is right. The following is my
description:
----
A CGI program parse a client request through environment variables. Some
of these variables may change for each HTTP request. The web server starts a new
system process for each request. Thus the server must give the Java VM a new set
of environment variables for each client request. Both the Java VM and the
CGI program end this request and restart for next request.

The Java Servlets technology process each request with either doGet() or
doPost() method. Both of them read a client request from the object
"HttpServletRequest", and respond the client with the object
"HttpServletResponse". It avoids using environment variables.

That is why running XQuery programs as CGI takes more time than as
Servlets.
---

Yes, that is correct.  Running a servlet only requires starting up the
Java VM once, on the first request.  If your web server is Tomcat,
you already have a JVM running, of course.
--
        --Per Bothner
address@hidden   http://per.bothner.com/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]