The first thing you need to do is to configure your web application to work with Vroom Request Dispatcher. For that please read the Blog Entry What is Vroom Request Dispatcher?
Once the above step is complete, you need to add following entries in /WEB-INF/vrd-config.xml file: (You may only include the entries that are needed)
<vrd-config>
<request pattern="/path/to/scripts/.*.py">
<invocation method-name="net.openkoncept.vroom.vrd.jython.JythonRequestDispatcher.dispatch"/>
</request>
<request pattern="/path/to/scripts/.*.rb">
<invocation method-name="net.openkoncept.vroom.vrd.jruby.JRubyRequestDispatcher.dispatch"/>
</request>
<request pattern="/path/to/scripts/.*.groovy">
<invocation method-name="net.openkoncept.vroom.vrd.groovy.GroovyRequestDispatcher.dispatch"/>
</request>
<request pattern="/path/to/scripts/.*.js">
<invocation method-name="net.openkoncept.vroom.vrd.javascript.JavaScriptRequestDispatcher.dispatch"/>
</request>
</vrd-config>
For Jython, you need to add JVM parameter as follows:
Like servlet, there is an entry point for these scripts and that is a no argument public method named vrd_main , to request and response objects are accessible in the script using variables vrd_hreq (javax.servlet.http.HttpServletRequest) and vrd_hres (javax.servlet.http.HttpServletResponse). Below are the samples in each scripting language:
-Dpython.path=/path/to/jython-home/Lib:/path/to/jython-home/Lib/site-packages
Jython:
def vrd_main():
res = vrd_hres
res.contentType = 'text/html'
w = res.writer
w.print('Hello World')
w.flush()
JRuby:
def vrd_main()
res = $bsf.lookupBean('vrd_hres')
res.contentType = 'text/html'
w = res.writer
w.print('Hello World')
w.flush()
end
Groovy:
def vrd_main() {
res = vrd_hres
res.contentType = 'text/html'
w = res.writer
w.print('Hello World')
w.flush()
}
JavaScript:
function vrd_main() {
res = vrd_hres
res.contentType = 'text/html'
w = res.writer
w.print('Hello World')
w.flush()
}