From: Robert W. B. <rb...@di...> - 2001-02-16 17:24:22
|
Hello Jaraslav, On Fri, 16 Feb 2001, Jaroslav Gergic wrote: > > >Thak you for the tip! I will optionally upgrade - > > > > The change that brian describe is in org.python.util.PyServlet. Since > > you can't possible be using this class (because it is completely new) > > you will not find any benefits by upgrading. Unless you also begin to > > use org.python.util.PyServlet. > > Yes, I checked CVS and PyServlet seems also interesting > to me. I downloaded and compiled it but I can not > make it working I am constantly getting: > > javax.servlet.ServletException: Could not create Jython > servletTraceback (innermost last): > File "D:\develo\tomcat3.2b6\webapps\hello\hw.py", line 1, in ? > NameError: javax > > (I am testing Hello World servlet distributed with PyServlet:) > ---sample--- > class hello(HttpServlet): > def doGet(self,req, res): > res.setContentType("text/html"); > out = res.getOutputStream() > print >>out, "<html>" > print >>out, "<head><title>Hello World, How are we?</title></head>" > print >>out, "<body>Hello World, how are we?" > print >>out, "</body>" > print >>out, "</html>" > out.close() > return > ---end--- > > It also does not work even when I try to write > "class hello(javax.servet.http.HttpServlet)" > > and in case I try to import the interface: > > ---sample--- > from javax.servlet.http import HttpServlet > > class hello(HttpServlet): > ... > ---end--- You are correct, the import and base class is required. > I get: > javax.servlet.ServletException: No callable (class or function) named > hw in D:\develo\tomcat3.2b6\webapps\hello\hw.py The class name and file name need to match. Much like class hello would be defined in hello.java, Jython's class hello(HttpServlet) should be in a hello.py file. Remember PyServlet uses: PyObject cls = interp.get(name); and "name" is the filename without the extension. > (the script should probably evaluate to a single node...?) > > *** > I is interesting for me, because my application (python based > templates in Java + Tomcat) > works normally using the CLASSPATH trick described earlier. > I think there is some subtle difference between my CLASSPATH > handling and PyServlet classpath handling. > Can something be wrong with the following lines?: > ---from PyServlet--- > PySystemState sys = Py.getSystemState(); > sys.add_package("javax.servlet"); > sys.add_package("javax.servlet.http"); > sys.add_package("javax.servlet.jsp"); > sys.add_package("javax.servlet.jsp.tagext"); > ---end--- > > Anyway - PyServlet is good idea, I planned to write > something similar myself in the future, > and PyServlet saves me some time. > I hope I will get this thing working soon too. It's only moments away... -Robert |