Skip to content

Instantly share code, notes, and snippets.

@sheki
Created August 9, 2011 10:20
Show Gist options
  • Save sheki/1133714 to your computer and use it in GitHub Desktop.
Save sheki/1133714 to your computer and use it in GitHub Desktop.
Scalatra render static content - not working
class HTTPApiFilter extends ScalatraFilter with ScalateSupport
{
get("/api/"){
<html>
<body>
<h1>Hello, world!</h1>
<p>This is the HTTP API. What are you looking for</p>
</body>
</html>}
get("/api/staticpage")
{
val templatePath = "/WEB-INF/scalate/templates/" +"form"+ ".html"
println(servletContext.getResource(templatePath)) //THIS IS NULL ?? What am I doing wrong?
servletContext.getResource(templatePath) match
{
case url: URL =>
contentType = "text/html"
println("It is a URL")
new File(templatePath)
case _ =>{
println("It is not an URL")
filterChain.doFilter(request, response)}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment