velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vaneet Sharma <Van...@iwg.info>
Subject RE: Simple Question
Date Mon, 05 Aug 2002 11:05:24 GMT
hi
  set the path of velocity in your main servlet
 like this
  and u dont hvae to give complete path
  see below
  cheers
  
protected Properties loadConfiguration(ServletConfig config)
       throws IOException, FileNotFoundException {

    String propsFile = config.getInitParameter(INIT_PROPS_KEY);
    
    /**
     * Now convert to an absolute path relative to the webapp root
     * This will work in a decently implemented servlet 2.2
     * container like Tomcat.
     */
    if (propsFile != null) {

      String realPath = getServletContext().getRealPath(propsFile);

      if (realPath != null) {
        propsFile = realPath;
      }
    }

    Properties p = new Properties();
    p.load(new FileInputStream(propsFile));

    /**
     * Now, lets get the two elements we care about, the
     * template path and the log, and fix those from relative
     * to the webapp root, to absolute on the filesystem, which is
     * what velocity needs
     */
    String path = p.getProperty("file.resource.loader.path");

    if (path != null) {

      path = getServletContext().getRealPath(path);
      p.setProperty("file.resource.loader.path", path);
    }

    path = p.getProperty("runtime.log");

    if (path != null) {

      path = getServletContext().getRealPath(path);
      p.setProperty("runtime.log", path);
    }

    return p;
  }


vaneet

-----Original Message-----
From: RIBEIRO Paulo Jorge [mailto:pribeiro@enabler.pt]
Sent: 05 August 2002 12:49
To: velocity-user@jakarta.apache.org
Subject: Simple Question


Hello,

I have a simple question. Let's suppose that I have a template in the
D:\velocity\templates directory. I tryed to use the following instruction to
get the template:

getTemplate("D:\\velocity\\templates\\template.vm") 
but it doesn't work. My question is how can I specify a template with a
complete path.

Thanks

Paulo


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

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