velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <geirmagnusso...@yahoo.com>
Subject Re: The "proper" way to configure/deploy Velocity servlets on an app server?
Date Mon, 12 Nov 2001 09:13:48 GMT

You never can be sure who's lurking around :)


On 11/12/01 4:05 AM, "Endre StĂžlsvik" <Endre@Stolsvik.com> wrote:

> On Sun, 11 Nov 2001, Blair Martin wrote:
> 
> | Initially, I tried using the file resource loader but this doesn't seem to
> | be a good idea because it's difficult to locate the templates. The app
> | server deals with .ear/.war.jar files so I don't even know what the real
> | path to the template files would be ( getServletContext().getRealPath()
> | returns null ). So I next tried class path resource loader after packaging
> | the template files in a .jar in the WEB-INF/lib directory. This worked. Is
> | this the best way to do it? Is there something I'm missing with using file
> | resource loader?
> 
> I'm no Velocity expert, but this sounds very right. (Or you could use
> servlet resource loading). Read my next answer to get why..
> 
> |
> | The uncertainty of runtime paths also has me confused about where to put a
> | properties file (and where velocity.log is written). I know you can specify
> | a path as an init-parameter in web.xml but it's unclear what the path is
> | relative to. In other words, at runtime the servlet doesn't seem to know
> | anything about the web app root (ie. the location of WEB-INF). In my case,
> | if default locations are used (no paths specified) than velocity.log, for
> | example, is written to the iPortal bin directory (\iportal\ipas3\bin). I
> | guess what I'm asking is how do I get the full, runtime path to the web app
> | root. As I write this I realize I'm not being totally Velocity-centric with
> | my question but perhaps someone who addresses the earlier question might be
> | able to help.
> 
> There might be no path for your war/ear file. It might come off a
> database.. Or a CDrom.. or whatever. So do not expect paths to exist at
> all.
> 
> Instead, you will have to rely on the servlet container to fetch stuff for
> you. (btw; a servlet container shall provide temporary directory for you
> to write files i, you find this by some env.variable).
> 
> To get things relative to the webroot, use
> servlet.getServletConfig().getServletContext().getResource[AsStream](String
> resource). Read the javadocs. This resource will come off the webroot, and
> to get stuff inside WEB-INF, you specify e.g.
> "/WEB-INF/thefile.properties" as the resource name.
> 

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"He who throws mud only loses ground." - Fat Albert


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message