public class PyServlet
extends javax.servlet.http.HttpServlet
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>
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SKIP_INIT_NAME |
Constructor and Description |
---|
PyServlet() |
Modifier and Type | Method and 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) |
public static final java.lang.String SKIP_INIT_NAME
public void init()
init
in class javax.servlet.GenericServlet
public void service(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res) throws javax.servlet.ServletException, java.io.IOException
service
in interface javax.servlet.Servlet
service
in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
java.io.IOException
public void destroy()
destroy
in interface javax.servlet.Servlet
destroy
in class javax.servlet.GenericServlet
public void reset()