velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@optonline.net>
Subject Re: Symbol escaped in a property
Date Thu, 08 Nov 2001 13:24:27 GMT
On 11/8/01 8:00 AM, "Vitaly Repetenko" <vit@mtu.ru> wrote:

> 
> 
> "Geir Magnusson Jr." wrote:
> 
>> On 11/8/01 7:31 AM, "Vitaly Repetenko" <vit@mtu.ru> wrote:
>> 
>>> Good day!
>>> 
>>> "Geir Magnusson Jr." wrote:
>>> 
>>>> On 11/6/01 6:55 AM, "Vitaly Repetenko" <vit@mtu.ru> wrote:
>>>> 
>>>>>>> 
>>>>>>> configuration.getString("timestampstatement") result is:
>>>>>>> select a from t1
>>>>>>> 
>>>>>>> Thanks in advance!
>>>>>>> Vitaly
>>>>>> 
>>>>>> I thought we had a problem like this about 6 months ago, and Leon
>>>>>> submitted
>>>>>> a patch and was applied.  I assume this is a recent version of Velocity?
>>>>> 
>>>>> Velocity Version: Nightly 28 oct. 2001
>>>>> 
>>>> 
>>>> Heh.  You can't argue that's its old :)
>>>> 
>>>> I need to fix that class anyway, so I will spend some time on it today.
>>> 
>>> It still does not work (commas escaped in properties) :(
>>> 
>>> I have found that it works: select a from a\\\\, b
>> 
>> This dones't make sense :)
>> 
>> We test the configuration stuff in our testbed, and do things with ,'s
>> 
>> Take a look at the CommonsExtPropTestCase in o.a.v.test
> 
> I see.
> I use Velocity in servlets. May be I do something wrong during loading
> properties.
> In this configuration I can not use escape symbol. :(
> It works only when I add \\\\ in a property.
> Could you help me?
> 
>   protected Properties loadConfiguration(ServletConfig config )
>       throws IOException, FileNotFoundException
>   {
>       Properties p = new Properties();
> 
>       String propsFile = config.getInitParameter(INIT_PROPS_KEY);
> 
>       if ( propsFile != null )
>       {
>           String realPath = getServletContext().getRealPath(propsFile);
> 
>           if ( realPath != null )
>           {
>               propsFile = realPath;
>           }
>       }
> 
>       p.load( new FileInputStream(propsFile) );
> 
>       return p;
>   }
> 
> Thanks in advance,
> Vitaly

That's the problem.  I think the Properties is messing you up.

I would override the new initVelocity() method in VelocityServlet, load an
ExtendedProperties (from org.apache.commons)

Then call 

Velocity.setExtendedProperties()
Velocity.init()

There are some details missing, but I hope this conveys the idea.  The
ExtendedProperties  respects the, and prevents vectorization...

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



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