You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Blair Martin <bl...@mindspring.com> on 2001/11/13 01:51:19 UTC

Re: The "proper" way to configure/deploy Velocity servlets on anapp server?

> 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.

Excellent. This is exactly the information I needed.

I've done something like this in loadConfiguration:

        Properties p = new Properties();
        String propsFile = "/velocity.properties";
        InputStream istream =
getServletContext().getResourceAsStream(propsFile);
        if ( istream != null )
{            p.load( istream );        }

Works great. Thanks.

Blair



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: The "proper" way to configure/deploy Velocity servlets on anapp server?

Posted by Blair Martin <bl...@mindspring.com>.
Good point.

Blair


> One thing to consider is that putting the file in "/" means that, in
> general, it's accessible as a web document (e.g.
> http://server:port/context/velocity.properties). If you put it in WEB-INF
as
> Endre originally mentioned, it can't be accessed because the spec dictates
> that that directory not be accessible.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: The "proper" way to configure/deploy Velocity servlets on anapp server?

Posted by Donnie Hale <do...@haleonline.net>.
Blair,

One thing to consider is that putting the file in "/" means that, in
general, it's accessible as a web document (e.g.
http://server:port/context/velocity.properties). If you put it in WEB-INF as
Endre originally mentioned, it can't be accessed because the spec dictates
that that directory not be accessible.

FWIW...

Donnie


-----Original Message-----
From: Blair Martin [mailto:blair1@mindspring.com]
Sent: Monday, November 12, 2001 7:51 PM
To: Velocity Users List
Subject: Re: The "proper" way to configure/deploy Velocity servlets on
anapp server?


> 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.

Excellent. This is exactly the information I needed.

I've done something like this in loadConfiguration:

        Properties p = new Properties();
        String propsFile = "/velocity.properties";
        InputStream istream =
getServletContext().getResourceAsStream(propsFile);
        if ( istream != null )
{            p.load( istream );        }

Works great. Thanks.

Blair



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>