You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by carsten nichte <ca...@t-systems.com> on 2002/03/20 17:33:47 UTC

newby : reading velocity.properties from web.xml failed

Hi to all,

im new to velocity, and have the typical starting problems:
I want to read te velocity.properties File from the web.xml.

I´ve the following configuration:

My web.xml: (in WEB-INF Folder)
---------------------------------------------
    <servlet>
        <servlet-name>zerf</servlet-name>
        <servlet-class>zerf.ZnSignController</servlet-class>
      <init-param>
        <param-name>properties</param-name>
        <param-value>/WEB-INF/conf/velocity.properties</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
    </servlet>

My velocity.properties: (in WE-INF/conf/)
---------------------------------------------

file.resource.loader.path = /templates
runtime.log = /velocity.log


My servlet does the following:
---------------------------------------------
protected Properties loadConfiguration(ServletConfig config)throws IOException, FileNotFoundException{

String propsFile = config.getInitParameter(INIT_PROPS_KEY); // where INIT_PROPS_KEY = "properties"

... Result: propsFile=null;  // .... so any following code is obsolet... 

This Code-snipplet is from one of the various examples.
I dont´t understand why it doesn´t work.
What does getInitParameter() exactly.

Any solutions ???

Best regards

Carsten Nichte


}




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


Re: newbie : reading velocity.properties from web.xml failed

Posted by carsten nichte <ca...@t-systems.com>.
Her is my totally complete web.xml:
------------------------------------

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
    <servlet>
        <servlet-name>zerf</servlet-name>
        <servlet-class>zerf.ZnSignController</servlet-class>
      <init-param>
        <param-name>properties</param-name>
        <param-value>/WEB-INF/conf/velocity.properties</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
    </servlet>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
    <welcome-file>
            index.jsp
        </welcome-file>
    <welcome-file>
            index.html
        </welcome-file>
    <welcome-file>
            index.htm
        </welcome-file>
    </welcome-file-list>
</web-app>

And so it is:

.. Result: propsFile=null;

Is it possible that there is a error in the web.xml file? --- i found nothig (but that means nothing..)

+
+
+
+

Geir Magnusson Jr. wrote:

>On 3/20/02 11:33 AM, "carsten nichte" <ca...@t-systems.com> wrote:
>
>>Hi to all,
>>
>>im new to velocity, and have the typical starting problems:
>>I want to read te velocity.properties File from the web.xml.
>>
>>IŽve the following configuration:
>>
>>My web.xml: (in WEB-INF Folder)
>>---------------------------------------------
>>  <servlet>
>>      <servlet-name>zerf</servlet-name>
>>      <servlet-class>zerf.ZnSignController</servlet-class>
>>    <init-param>
>>      <param-name>properties</param-name>
>>      <param-value>/WEB-INF/conf/velocity.properties</param-value>
>>    </init-param>
>>    <load-on-startup>1</load-on-startup>
>>  </servlet>
>>
>
>I assume this is just a snippet?  It's not complete if not...
>
>>My velocity.properties: (in WE-INF/conf/)
>>---------------------------------------------
>>
>>file.resource.loader.path = /templates
>>runtime.log = /velocity.log
>>
>>
>>My servlet does the following:
>>---------------------------------------------
>>protected Properties loadConfiguration(ServletConfig config)throws
>>IOException, FileNotFoundException{
>>
>>String propsFile = config.getInitParameter(INIT_PROPS_KEY); // where
>>INIT_PROPS_KEY = "properties"
>>
>>... Result: propsFile=null;  // .... so any following code is obsolet...
>>
>>This Code-snipplet is from one of the various examples.
>>I dontŽt understand why it doesnŽt work.
>>What does getInitParameter() exactly.
>>
>
>It returns to you the value of the <init-param> with the same <param-name>
>as the arg to the function.
>
>It's obvious why it doesn't work (unless your web.xml is really as you
>present it...)
>
>
>
>

-- 
Carsten Nichte
Dipl.Ing. Nachrichtentechnik

T-Systems Solutions for Research GmbH
Solution Center ADV
Postanschrift: Linder Höhe, 51147 Köln, Geb.1
Telefon:  +49 2203 601-4534
Telefax:  +49 2203 601-3718
E-Mail: carsten.nichte@t-systems.com
http://www.t-systems.de

////////////////////////////////////////////////////////////



Re: newby : reading velocity.properties from web.xml failed

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 3/20/02 11:33 AM, "carsten nichte" <ca...@t-systems.com> wrote:

> Hi to all,
> 
> im new to velocity, and have the typical starting problems:
> I want to read te velocity.properties File from the web.xml.
> 
> I´ve the following configuration:
> 
> My web.xml: (in WEB-INF Folder)
> ---------------------------------------------
>   <servlet>
>       <servlet-name>zerf</servlet-name>
>       <servlet-class>zerf.ZnSignController</servlet-class>
>     <init-param>
>       <param-name>properties</param-name>
>       <param-value>/WEB-INF/conf/velocity.properties</param-value>
>     </init-param>
>     <load-on-startup>1</load-on-startup>
>   </servlet>
> 

I assume this is just a snippet?  It's not complete if not...

> My velocity.properties: (in WE-INF/conf/)
> ---------------------------------------------
> 
> file.resource.loader.path = /templates
> runtime.log = /velocity.log
> 
> 
> My servlet does the following:
> ---------------------------------------------
> protected Properties loadConfiguration(ServletConfig config)throws
> IOException, FileNotFoundException{
> 
> String propsFile = config.getInitParameter(INIT_PROPS_KEY); // where
> INIT_PROPS_KEY = "properties"
> 
> ... Result: propsFile=null;  // .... so any following code is obsolet...
> 
> This Code-snipplet is from one of the various examples.
> I dont´t understand why it doesn´t work.
> What does getInitParameter() exactly.

It returns to you the value of the <init-param> with the same <param-name>
as the arg to the function.

It's obvious why it doesn't work (unless your web.xml is really as you
present it...)




-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin



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