A way you can get the Servlet context is like this:
LiftRules.context match {
case context: HTTPServletContext => // do something with
context.ctx which is the javax.servlet.ServletContext
case _ => // do something when the context is not a servlet
context, perhaps log an error
}
The reason you need the match is because Lift can run on non-servlet
web containers, so Lift does not guarantee there is a Servlet context
in scope.
Hope that helps,
-Ross
On Nov 27, 2009, at 10:51 AM, jhonig wrote:
> LS,
>
> After Ross' kind invitation to post any other questions I might have,
> I'll start with
> this one:
>
> The web application I am developing needs a scratch directory to white
> scaled
> images to. I first try to use a subdir of /tmp and put a symbolic
> link in place to
> access that directory from my project's context. However, this got me
> an
> error message (something about an aliased resource), so after some
> searching
> around I decided the best way is to create a directory inside WEF-INF
> and
> access it through getServletContext ().getRealPath ("/...").
>
> From the APIdocs I found out that an instance of a ServiceContext is
> passed
> to HTTPServletContext, but I haven't been able to find if that is the
> instance I
> need, or how to get an instance of HTTPServletContext...
>
> Note: I am currently able to read/write temporary finds when running
> through
> mvn getty:run, but I need a solution that still works when I deploy a
> war with
> an existing jetty server.
>
> Thanks for any hints!
>
> Job Honig
>
> --
>
> You received this message because you are subscribed to the Google
> Groups "Lift" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]
> .
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en
> .
>
>
--
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en.