osdir.com
mailing list archive

Subject: Problems with Properties - msg#00199

List: jakarta.velocity.user

Date: Prev Next Index Thread: Prev Next Index
Hi,

I'm trying to use to set more than a time a Velocity propertia FILE_RESOURCE_LOADER_PATH, but i don't have success.
this set just a first time. any help will be coming well.
I am trying to make:

String prefix;
if (templateFile.getPath().charAt(0) =='/'){
prefix = "";
} else{
prefix = Project.getInstance().getProjectRoot().getAbsolutePath()+"/";
}
Velocity v = new Velocity();
System.out.println("resource loader: "+prefix +templateFile.getParentFile().getPath());
if (v.getProperty(v.FILE_RESOURCE_LOADER_PATH) == null){
v.addProperty(v.FILE_RESOURCE_LOADER_PATH, prefix +templateFile.getParentFile().getPath());

} else{
v.setProperty(v.FILE_RESOURCE_LOADER_PATH, prefix +templateFile.getParentFile().getPath());
}
System.out.println("getProperty: "+v.getProperty(v.FILE_RESOURCE_LOADER_PATH));

and i get:

resource loader: /home/leonardo/projetos/PQU/codegen/vsl/finder
getProperty: /home/leonardo/projetos/PQU/codegen/vsl/finder

resource loader: /home/leonardo/projetos/PQU/codegen/vsl/entity
getProperty: /home/leonardo/projetos/PQU/codegen/vsl/finder

Regards,

--
/**
* Leonardo Andersen Lopes
* Java Programmer
* Datasul CRM
*
* Florianopolis - SC - Brasil
*
* notinf@xxxxxxxxxx
*/


Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

RE: getRealPath in IAS6.5 by VelocityServlet

We had that problem with Weblogic: if your app server is configured to not unpack your WAR/EAR files, getRealPath() _must_ fail, since the individual files are not on your file system. For the Velocity configuration file, I ended up re-writing VelocityServlet to use ServletContext.getResourceAsStream(). (This is much more portable than getRealPath(), but only works for reading files, not writing them: if you need to write files, you'll need some way for customers to just hand you the directory name(s).) -- Bill K. > -----Original Message----- > From: Yagantappa Jaya [mailto:yag@xxxxxxxxxxxxxxx] > Sent: Thursday, September 26, 2002 10:11 AM > To: Velocity Users List > Subject: getRealPath in IAS6.5 by VelocityServlet > > > Hello, > I am using VelocityServlet and iPlanet Application Server > 6.5. I got > > a problem in getting the real path. Deployment of application is done > thru .ear file. Here is the code which I used in my servlet for > loadConfiguration. > > protected Properties loadConfiguration(ServletConfig config ) > throws IOException, FileNotFoundException > { > String path = ""; > Properties p = new Properties(); > path = config.getServletContext().getRealPath("/"); > System.out.println("path = " + path); > if (path == null) > { > System.out.println(" SampleServlet.loadConfiguration() : > unable to " > + "get the current webapp root. Using > '/'.Please fix."); > path = "/"; > } > > p.setProperty( Velocity.FILE_RESOURCE_LOADER_PATH, path ); > p.setProperty( "runtime.log", path + "velocity.log" ); > return p; > } > > > In the above code, when I print the path value, it is printing null > value instead document root directory. Please help in solving this > problem. > > Thanks in advance. > Yag > > > > > -- > To unsubscribe, e-mail: > <mailto:velocity-user-unsubscribe@xxxxxxxxxxxxxxxxxx> > For additional commands, e-mail: <mailto:velocity-user-help@xxxxxxxxxxxxxxxxxx>

Next Message by Date: click to view message preview

Re: Velocity (was RE: [SECURITY] Apache Tomcat 4.x JSP source disclosure vulnerability)

I have promised not to use Tomcat-Dev for this, so I'm answering privately and I'm sending a CC to Velocity-User list, where it belongs. That's an excellent point and is exactly what I'm talking about. Again, who creates the context object? The programmers, NOT the web designers. As for YATL, anyone with half a brain and one afternoon can learn Velocity. JSP is a completely different story because it's Java. On the topic of programming in Velocity. Well, I've seen some really complicated code out there. And you know what, it's all crap. The code beyond simple if's and foreach directives should not be in any template but rather in the controller or the model, written in Java, by the programmers. If programmers are forcing designers to write complicated Velocity constructs or are doing it themselves, they are asking for trouble. Bojan On Fri, 2002-09-27 at 00:23, Dennis Doubleday wrote: > Bojan, > > Just move the code you wrote into a context object, reference it and > poof! Velocity gets OutOfMemory, too. Bad code is limited to front ends. > > Velocity is nice. It is an excellent project, and Geir is possibly the > most responsive and helpful project leader I have ever encountered. > > But there IS programming in a Velocity page--it's just in Yet Another > Templating Language, one that both your developers and your web > designers have to learn. That creates opportunities for confusion. > (Especially where velocimacros are involved.) > > > -----Original Message----- > > From: Bojan Smojver [mailto:bojan@xxxxxxxxxxxxx] > > Sent: Wednesday, September 25, 2002 10:34 PM > > To: Tomcat Developers List > > Subject: Re: [SECURITY] Apache Tomcat 4.x JSP source > > disclosure vulnerability > > > > > > Not if: > > > > runtime.interpolate.string.literals = false > > > > Bojan > > > > Quoting Tim Funk <funkman@xxxxxxxxxx>: > > > > > That's what code reviews are for and in absence of that - > > firing your > > > developers. > > > > > > Wouldn't I also get an out of memory with this in Velocity? > > > > > > #set($oom = > > "0000000000000000000000000000000000000000000000000000" ) > > > #foreach( $i in [-2147483648..2147483648] ) #set($oom = > > > "$oom$oom$oom$oom$oom$oom$oom$oom$oom$oom$oom$oom$oom$oom" ) #end > > > > > > Bad code can kill ANY system for the determined(disgruntled) > > > developer. > > > > > > > > > Bojan Smojver wrote: > > > > All right then, let's talk about JSP's. If I host my > > clients' JSP's > > > > on my > > > server > > > > and a web designer puts this in (BTW, he wasn't forced, he simply > > > > decided > > > he > > > > wanted to do it): > > > > > > > > ----------------------------------------------- > > > > Hashtable strings = new Hashtable(); > > > > int i=0; > > > > while (true) > > > > { > > > > strings.put ("dead"+i, new StringBuffer(999999)); > > > > } > > > > ----------------------------------------------- > > > -- > To unsubscribe, e-mail: <mailto:tomcat-dev-unsubscribe@xxxxxxxxxxxxxxxxxx> > For additional commands, e-mail: <mailto:tomcat-dev-help@xxxxxxxxxxxxxxxxxx> >

Previous Message by Thread: click to view message preview

Templates in DB instead of on Disk

Hi, Is it possible to store templates in another location than Disk; ie Ldap and/or a DB? I looked at the Javadocs for the Template object but that seems to go through Template = Velocity.getTemplate("NameOfTemplate") I'm using Velocity in EJBeans reading from Disk, which works fine for now. However I'm thinking about moving the 3 or 4 templates I use for generating messages to another source. Thx /colin

Next Message by Thread: click to view message preview

Re: Velocity (was RE: [SECURITY] Apache Tomcat 4.x JSP source disclosure vulnerability)

I have promised not to use Tomcat-Dev for this, so I'm answering privately and I'm sending a CC to Velocity-User list, where it belongs. That's an excellent point and is exactly what I'm talking about. Again, who creates the context object? The programmers, NOT the web designers. As for YATL, anyone with half a brain and one afternoon can learn Velocity. JSP is a completely different story because it's Java. On the topic of programming in Velocity. Well, I've seen some really complicated code out there. And you know what, it's all crap. The code beyond simple if's and foreach directives should not be in any template but rather in the controller or the model, written in Java, by the programmers. If programmers are forcing designers to write complicated Velocity constructs or are doing it themselves, they are asking for trouble. Bojan On Fri, 2002-09-27 at 00:23, Dennis Doubleday wrote: > Bojan, > > Just move the code you wrote into a context object, reference it and > poof! Velocity gets OutOfMemory, too. Bad code is limited to front ends. > > Velocity is nice. It is an excellent project, and Geir is possibly the > most responsive and helpful project leader I have ever encountered. > > But there IS programming in a Velocity page--it's just in Yet Another > Templating Language, one that both your developers and your web > designers have to learn. That creates opportunities for confusion. > (Especially where velocimacros are involved.) > > > -----Original Message----- > > From: Bojan Smojver [mailto:bojan@xxxxxxxxxxxxx] > > Sent: Wednesday, September 25, 2002 10:34 PM > > To: Tomcat Developers List > > Subject: Re: [SECURITY] Apache Tomcat 4.x JSP source > > disclosure vulnerability > > > > > > Not if: > > > > runtime.interpolate.string.literals = false > > > > Bojan > > > > Quoting Tim Funk <funkman@xxxxxxxxxx>: > > > > > That's what code reviews are for and in absence of that - > > firing your > > > developers. > > > > > > Wouldn't I also get an out of memory with this in Velocity? > > > > > > #set($oom = > > "0000000000000000000000000000000000000000000000000000" ) > > > #foreach( $i in [-2147483648..2147483648] ) #set($oom = > > > "$oom$oom$oom$oom$oom$oom$oom$oom$oom$oom$oom$oom$oom$oom" ) #end > > > > > > Bad code can kill ANY system for the determined(disgruntled) > > > developer. > > > > > > > > > Bojan Smojver wrote: > > > > All right then, let's talk about JSP's. If I host my > > clients' JSP's > > > > on my > > > server > > > > and a web designer puts this in (BTW, he wasn't forced, he simply > > > > decided > > > he > > > > wanted to do it): > > > > > > > > ----------------------------------------------- > > > > Hashtable strings = new Hashtable(); > > > > int i=0; > > > > while (true) > > > > { > > > > strings.put ("dead"+i, new StringBuffer(999999)); > > > > } > > > > ----------------------------------------------- > > > -- > To unsubscribe, e-mail: <mailto:tomcat-dev-unsubscribe@xxxxxxxxxxxxxxxxxx> > For additional commands, e-mail: <mailto:tomcat-dev-help@xxxxxxxxxxxxxxxxxx> >
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by