Package org.python.util
Class PyServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.python.util.PyServlet
-
- All Implemented Interfaces:
java.io.Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
public class PyServlet extends javax.servlet.http.HttpServlet
This servlet is used to re-serve Jython servlets. It stores bytecode for Jython servlets and re-uses it if the underlying .py file has not changed.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, "
in web.xml for the PyServlet context:Hello World, How are we? " print >>out, "Hello World, how are we?" print >>out, "" print >>out, "" out.close()<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.5</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
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
SKIP_INIT_NAME
-
Constructor Summary
Constructors Constructor Description PyServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
void
init()
void
reset()
Clears the cache of loaded servlets and makes a new PythonInterpreter to service further requests.void
service(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res)
-
-
-
Field Detail
-
SKIP_INIT_NAME
public static final java.lang.String SKIP_INIT_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init()
- Overrides:
init
in classjavax.servlet.GenericServlet
-
service
public void service(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res) throws javax.servlet.ServletException, java.io.IOException
- Specified by:
service
in interfacejavax.servlet.Servlet
- Overrides:
service
in classjavax.servlet.http.HttpServlet
- Throws:
javax.servlet.ServletException
java.io.IOException
-
destroy
public void destroy()
- Specified by:
destroy
in interfacejavax.servlet.Servlet
- Overrides:
destroy
in classjavax.servlet.GenericServlet
-
reset
public void reset()
Clears the cache of loaded servlets and makes a new PythonInterpreter to service further requests.
-
-