If it's returning nulls, sounds to me like it's not finding that
file. I forget what the root of of ServletContext.getResource() is -
I'm using to having things in WEB-INF/classes to read them off the
classpath.
I believe you might need to put the "/WEB-INF" as part of your path,
like "/WEB-INF/views/dashboard.html".
However, if you're just serving a static file, why have it in WEB-
INF? That directory's more for code things. ScalatraServlet has a
handler that will serve a static file in the top-level of your webapp
if no route is defined for it:
https://github.com/scalatra/scalatra/blob/develop/core/src/main/scala/org/scalatra/ScalatraServlet.scala#L65
That's the default behaviour for Filters, as well.
If you really do need to muck with the request / response
programaticlly, yes, you can return a File reference, and Scalatra
will serve it, with the code here:
https://github.com/scalatra/scalatra/blob/develop/core/src/main/scala/org/scalatra/ScalatraServlet.scala#L65
The ServletContext is available for you as a variable called
"servletContext":
http://www.scalatra.org/2.1/book/#ServletContext
So returning new File(servletContext.getResource("/WEB-INF/views/
dashboard.html")) should work.
You can also add to that renderPipeline, perhaps something that will
turn URLs into Files for you, and do the same thing.
-Leif