-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathPyServletInitializer.java
More file actions
37 lines (33 loc) · 1.29 KB
/
PyServletInitializer.java
File metadata and controls
37 lines (33 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package org.python.servlet;
import java.util.Properties;
import jakarta.servlet.ServletContextEvent;
import jakarta.servlet.ServletContextListener;
/**
* Initializes the jython runtime inside a servlet engine. Should be used with {@link PyFilter} to
* initialize the system before the filter starts. Add the following to web.xml to run the
* initializer:
*
* <pre>
* <listener>
* <listener-class>org.python.servlet.PyServletInitializer</listener-class>
* <load-on-startup>1</load-on-startup>
* </listener>
*</pre>
*
* To use modules from Python's standard library in servlets and filters initialized by this
* listener, either add the standard library to the lib directory in WEB-INF, or add python.home as
* a context-param. The latter can be done by adding the following to web.xml:
*
* <pre>
* <context-param>
* <param-name>python.home</param-name>
* <param-value>/usr/local/jython-2.5</param-value>
* </context-param>
* </pre>
*/
public class PyServletInitializer implements ServletContextListener {
public void contextInitialized(ServletContextEvent evt) {
PyServlet.init(new Properties(), evt.getServletContext());
}
public void contextDestroyed(ServletContextEvent evt) {}
}