You are mixing up 2 very different interfaces.
CGI - allows using any program that reads stdin and writes std out to
generate pages. In this case a web-server starts your program for
every incoming request and returns it's stdout contents to client. If
you are using CGI you could just write
print "<html><head/><body>Hello world!</body></html>";
This is arguably the simplest possible interface and most web-servers
support it (e.g. Lighttpd or Apache).
Java Servlets - is java API for request/response handlers. This is
what your code implies. Java servlets are deployed into a Java servlet
container (e.g. Jetty or Tomcat). Usually you should create a .war
archive and let your web-server to use it. Some servers allow just
putting your app into some directory. Please read manuals about Java
servlets for details. There are also recurring questions in this list
about servlets so you may serach jython-users archives.
On Thu, Mar 6, 2008 at 8:29 AM, <rachmat@...> wrote:
> yes, i'm using #!java -jar c:/jython-2.1/jython.jar
> but i'm found this page is blank,,,,
> why ? any solution ?
> this my script jython :
> #!java -jar c:/jython-2.1/jython.jar
> from javax.servlet.http import HttpServlet
> class JythonServlet1 (HttpServlet):
> def doGet(self,request,response):
> self.doPost (request,response)
> def doPost(self,request,response):
> toClient = response.getWriter()
> response.setContentType ("text/html")
> toClient.println("<html><head&><title>Servlet Test</title>" +
> "<body:<h1>Servlet Test</h1></body></html>")
> > On Wed, Mar 5, 2008 at 4:31 PM, <rachmat@...> wrote:
> >> dear all,
> >> if i using python cgi i can using script .py
> >> example :
> >> #!c:/Python25/python -u <-- if in jython cgi, how to ?
> >> .....
> > I presume it is
> > #!java -jar path/to/jython/jython.jar
> > However it is a bad idea to server pages this way as performance will
> > not be impressive :)
> > CGI starts process for every request and in case of Jython it will
> > start java machine along with interpreter itself.
> > I would suggest using Jython in some long running process: in a
> > web-server (Jetty for example) or use FastCGI interface.
> > Petr Gladkikh