All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.python.util.PyServletInitializer Maven / Gradle / Ivy

Go to download

Jython is an implementation of the high-level, dynamic, object-oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform.

The newest version!
package org.python.util;

import java.util.Properties;

import javax.servlet.ServletContextEvent;
import javax.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:
 *
 * 
 *   <listener>
 *       <listener-class>org.python.util.PyServletInitializer</listener-class>
 *       <load-on-startup>1</load-on-startup>
 *   </listener>
 *
* * 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: * *
 * <context-param>
 *     <param-name>python.home</param-name>
 *     <param-value>/usr/local/jython-2.5</param-value>
 * </context-param>
 * 
*/ public class PyServletInitializer implements ServletContextListener { public void contextInitialized(ServletContextEvent evt) { PyServlet.init(new Properties(), evt.getServletContext()); } public void contextDestroyed(ServletContextEvent evt) {} }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy