org.python.util
Class PyServlet

java.lang.Object
  extended byHttpServlet
      extended byorg.python.util.PyServlet

public class PyServlet
extends HttpServlet

This servlet is used to re-serve JPython servlets. It stores bytecode for JPython servlets and re-uses it if the underlying .py file has not changed.

Many people have been involved with this class:

If somebody is missing from this list, let us know.

e.g. http://localhost:8080/test/hello.py


 from javax.servlet.http import HttpServlet
 class hello(HttpServlet):
     def doGet(self, req, res):
         res.setContentType("text/html");
         out = res.getOutputStream()
         print >>out, ""
         print >>out, "Hello World, How are we?"
         print >>out, "Hello World, how are we?"
         print >>out, ""
         print >>out, ""
         out.close()
         return
 
in web.xml for the PyServlet context:
 <web-app>
     <servlet>
         <servlet-name>PyServlet</servlet-name>
         <servlet-class>org.python.util.PyServlet</servlet-class>
         <init-param>
             <param-name>python.home</param-name>
             <param-value>/usr/home/jython-2.1</param-value>
         </init-param>
     </servlet>
     <servlet-mapping>
         <servlet-name>PyServlet</servlet-name>
         <url-pattern>*.py</url-pattern>
     </servlet-mapping>
 </web-app>

 

See Also:
Serialized Form

Constructor Summary
PyServlet()
           
 
Method Summary
 void destroy()
           
 void init()
           
 void reset()
           
 void service(ServletRequest req, ServletResponse res)
          Implementation of the HttpServlet main method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PyServlet

public PyServlet()
Method Detail

init

public void init()

service

public void service(ServletRequest req,
                    ServletResponse res)
             throws ServletException,
                    IOException
Implementation of the HttpServlet main method.

Parameters:
req - the request parameter.
res - the response parameter.
Throws:
ServletException
IOException

reset

public void reset()

destroy

public void destroy()