Skip to content

Instantly share code, notes, and snippets.

@wytten
Forked from aalmiray/gist:5395913
Last active December 16, 2015 07:09
Show Gist options
  • Save wytten/5396905 to your computer and use it in GitHub Desktop.
Save wytten/5396905 to your computer and use it in GitHub Desktop.
A GSP (Groovy Server Pages) variation of the technique
<% import org.codehaus.groovy.control.CompilerConfiguration %>
<% import org.wyttenbach.dale.groovy.spaceship.* %>
<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
%>
<link rel="stylesheet" href="css/sample.css" type="text/css">
Here is a bunch of text
<hr/>
<%
// create a configuration
def config = new CompilerConfiguration()
// tweak the configuration
config.scriptBaseClass = 'org.wyttenbach.dale.groovy.spaceship.EngineScript'
// run your script
def shell = new GroovyShell(config)
def reader = new InputStreamReader(context.getResourceAsStream('/engine.groovy'))
engineScript = shell.evaluate(reader)
assert engineScript instanceof Engine
engineScript.start()
engineScript.stop()
%>
@wytten
Copy link
Author

wytten commented Apr 16, 2013

Note that the start/stop messages appear in the log, not on the page.
I am using maven jetty plugin for testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment