You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Davide Mora <d_...@yahoo.com> on 2001/03/30 11:38:20 UTC

escape characters in #set

Hi!

i writing a template for ANT, with a lot of ${..}, and
i found a little problem:

set ( $myvar = "\${project}")

because i want my $myvar contains "${project}" without
be used by velocity.

this cause an error:

org.apache.velocity.runtime.parser.TokenMgrError:
Lexical error at line 23, column 15.  Encountered: "$"
(36), after : "\"\\" 	at
org.apache.velocity.runtime.parser.ParserTokenManager.getNextToken(ParserTokenManager.java:3496)
	at
org.apache.velocity.runtime.parser.Parser.jj_scan_token(Parser.java:3052)
	at
org.apache.velocity.runtime.parser.Parser.jj_3R_48(Parser.java:2320)
	at
org.apache.velocity.runtime.parser.Parser.jj_3R_35(Parser.java:2446)
	at
org.apache.velocity.runtime.parser.Parser.jj_3R_21(Parser.java:2497)
	at
org.apache.velocity.runtime.parser.Parser.jj_3_6(Parser.java:2895)
	at
org.apache.velocity.runtime.parser.Parser.jj_2_6(Parser.java:2186)
	at
org.apache.velocity.runtime.parser.Parser.Expression(Parser.java:1495)
	at
org.apache.velocity.runtime.parser.Parser.Assignment(Parser.java:1546)
	at
org.apache.velocity.runtime.parser.Parser.Expression(Parser.java:1496)
	at
org.apache.velocity.runtime.parser.Parser.SetDirective(Parser.java:1437)
	at
org.apache.velocity.runtime.parser.Parser.Statement(Parser.java:268)
	at
org.apache.velocity.runtime.parser.Parser.process(Parser.java:218)
	at
org.apache.velocity.runtime.parser.Parser.parse(Parser.java:78)
	at
org.apache.velocity.runtime.Runtime.parse(Runtime.java:584)
	at
org.apache.velocity.Template.process(Template.java:159)
	at
org.apache.velocity.runtime.resource.ResourceManager.getResource(ResourceManager.java:336)
	at
org.apache.velocity.runtime.Runtime.getTemplate(Runtime.java:625)
	at
org.apache.velocity.app.Velocity.getTemplate(Velocity.java:461)


the workaround is:

set ($usd = "\$")
set ( $myvar = "$usd{project}")

Thank you,
Davide

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/?.refer=text

RE: Velocity FileResourceReader,How do I obtain the path and filename used ?

Posted by "Gerald E. Bennett" <mr...@austin.rr.com>.
Actually I would prefer both.

-----Original Message-----
From: gmj@mta6.srv.hcvlny.cv.net [mailto:gmj@mta6.srv.hcvlny.cv.net]On
Behalf Of Geir Magnusson Jr.
Sent: Sunday, April 15, 2001 12:10 PM
To: velocity-user@jakarta.apache.org
Subject: Re: Velocity FileResourceReader,How do I obtain the path and
filename used ?


"Gerald E. Bennett" wrote:
>
> When obtaining a template, if the resource is a FileResourceReader is
there
> a way to obtain the extended filename ?

Do you need to obtain it in your app, or just to the log?

>
> If not could this be added somehow ?
>
> I have tried the following in my code except not sure what to do for the
> "??":
>
> ResourceLoader resourceLoader=template.getResourceLoader();
> if(resourceLoader.getClassName().endsWith(".FileResourceLoader"))
>      {
>                     System.out.println("Parsing...");
>                     System.out.println("FileName:" +?? +"\nFilePath:"+??);
>      }
>
> Thanks


--
Geir Magnusson Jr.                               geirm@optonline.net
Developing for the web?  See http://jakarta.apache.org/velocity/


Re: Velocity FileResourceReader,How do I obtain the path and filename used ?

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
"Gerald E. Bennett" wrote:
> 
> When obtaining a template, if the resource is a FileResourceReader is there
> a way to obtain the extended filename ?

Do you need to obtain it in your app, or just to the log?

> 
> If not could this be added somehow ?
> 
> I have tried the following in my code except not sure what to do for the
> "??":
> 
> ResourceLoader resourceLoader=template.getResourceLoader();
> if(resourceLoader.getClassName().endsWith(".FileResourceLoader"))
>      {
>                     System.out.println("Parsing...");
>                     System.out.println("FileName:" +?? +"\nFilePath:"+??);
>      }
> 
> Thanks


-- 
Geir Magnusson Jr.                               geirm@optonline.net
Developing for the web?  See http://jakarta.apache.org/velocity/

Velocity FileResourceReader, How do I obtain the path and filename used ?

Posted by "Gerald E. Bennett" <mr...@austin.rr.com>.
When obtaining a template, if the resource is a FileResourceReader is there
a way to obtain the extended filename ?

If not could this be added somehow ?


I have tried the following in my code except not sure what to do for the
"??":

ResourceLoader resourceLoader=template.getResourceLoader();
if(resourceLoader.getClassName().endsWith(".FileResourceLoader"))
     {
		    System.out.println("Parsing...");
		    System.out.println("FileName:" +?? +"\nFilePath:"+??);
     }


Thanks


Re[2]: Velocity on weblogic

Posted by daljeetsingh <da...@softhome.net>.
Weblogic has these three folders setup at installation:

public_html: Put ur JSP/HTML etc
serverclasses: Put ur beans and other non reloadble classes
servletclasses:Put ur servlets here.

i have tried to put Web-inf in all the above folders. Doesn't help. With
the contexts it works, I have installed the war files that come with
struts. So within web applications it understnads the web-inf folder. 

Thanx
Daljeet Singh 
ecExperts India 
Ph:- (O) +91-11-4670906
(R) +91-11-7125680 
ICQ:- 75129600
Yahoo:- daljeetsinghmaken 

Re: Velocity on weblogic

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
daljeetsingh wrote:
> 
> That sounds fine. Maybe it does work.
> What if I am already into a project that doesnot use contexts as they
> are in TOMCAT. Just want to use velocity with the existing application.
> There are a lot of people who will be in a similar position.
> 
> We have an app that already works under the default folders and doesnot
> use contexts. Maybe I need to port this somehow.

Ok.  Tell us about the default folder setup...

 
> But i will keep u posted.
> 
> Thanks
> Daljeet Singh
> ecExperts India
> Ph:- (O) +91-11-4670906
> (R) +91-11-7125680
> ICQ:- 75129600
> Yahoo:- daljeetsinghmaken

-- 
Geir Magnusson Jr.                               geirm@optonline.net
Developing for the web?  See http://jakarta.apache.org/velocity/

Re[2]: Velocity on weblogic

Posted by daljeetsingh <da...@softhome.net>.
That sounds fine. Maybe it does work.
What if I am already into a project that doesnot use contexts as they
are in TOMCAT. Just want to use velocity with the existing application.
There are a lot of people who will be in a similar position. 

We have an app that already works under the default folders and doesnot
use contexts. Maybe I need to port this somehow.

But i will keep u posted.

Thanks
Daljeet Singh 
ecExperts India 
Ph:- (O) +91-11-4670906
(R) +91-11-7125680 
ICQ:- 75129600
Yahoo:- daljeetsinghmaken 

Re: Velocity on weblogic

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
daljeetsingh wrote:
> 
> Hello,
> 
> U see my problem I dont even know where this folder goes under weblogic
> 5.1

You'd think you would get good documentation for US$30,000.00 per
processor...

Hm. Looking at it, they aren't bad.

http://www.weblogic.com/docs51/classdocs/webappguide.html

Here's what I am guessing you will have to do...

1) setup a directory for your web app.  Assuming unix :

 /opt/mywebapp
 /opt/mywebapp/templates
 /opt/mywebapp/WEB-INF
 /opt/mywebapp/WEB-INF/lib
 /opt/mywebapp/WEB-INF/classes
 
where 'mywebapp' is the name of the webapp.  And it doesn't have top be
in /opt

2) Put the velocity-XX.jar into mywebapp/WEB-INF/lib above
3) Put the SampleServlet.class into the mywebapp/WEB-INF/classes above.
4) Put a web.xml with the following you have been quoting into
mywebapp/WEB-INF

 <?xml version="1.0" encoding="ISO-8859-1"?>
 
 <!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>MyServlet</servlet-name>
    <servlet-class>SampleServlet</servlet-class>
    <init-param>
        <param-name>properties</param-name>
        <param-value>velocity.properties</param-value>
    </init-param>
  </servlet>
 </web-app>
 

5) Put sample.vm into mywebapp/templates
6) make a file velocity.properties, place in mywebapp/ and make it
include the line

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

7) In the weblogic.properties file, add the line

   weblogic.httpd.webApp.mywebapp=/opt/mywebapp

8) Bounce or start weblogic.

If this does indeed work, please, please, *please* let me know, so we
can document this in our docs.  I will also provide a WAR somewhere to
make this easier for people.

geir

> It has public_html, serverclasses and servletclasses. I kept Web-inf in
> all three with a web.xml that contains:
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> 
> <!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>MyServlet</servlet-name>
>    <servlet-class>SampleServlet</servlet-class>
>    <init-param>
>        <param-name>properties</param-name>
>        <param-value>velocity.properties</param-value>
>    </init-param>
>  </servlet>
> </web-app>
> 

-- 
Geir Magnusson Jr.                               geirm@optonline.net
Developing for the web?  See http://jakarta.apache.org/velocity/

Re[2]: Velocity on weblogic

Posted by daljeetsingh <da...@softhome.net>.
Hello,

U see my problem I dont even know where this folder goes under weblogic
5.1

It has public_html, serverclasses and servletclasses. I kept Web-inf in
all three with a web.xml that contains:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!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>MyServlet</servlet-name>
   <servlet-class>SampleServlet</servlet-class>
   <init-param>
       <param-name>properties</param-name>
       <param-value>velocity.properties</param-value>
   </init-param>
 </servlet>
</web-app>

but i still cant access the servlet SampleServlet as MyServlet. I can
though access SampleServlet.

Will look further and let u know.

Thanks
Daljeet Singh 
ecExperts India 
Ph:- (O) +91-11-4670906
(R) +91-11-7125680 
ICQ:- 75129600
Yahoo:- daljeetsinghmaken 

Re: texen questions

Posted by Robert Burrell Donkin <Ro...@appleonline.net>.
"Geir Magnusson Jr." wrote:

> > 2. is texan currently under active development by velocity, or is the focus
> > mainly on torque on the turbine list?
>
> 'texen' -  'texan' is that guy in washinton...

aaarrghh - sloppy typing. apologies.

> It's an active part of the Velocity project.  If you are referring to
> the issue you raised last week, I apologize... lets do it now.... (need
> to review :)

nope - it's just that the example seemed a good place to start :-)

the example in the documentation didn't work for me so i had to modify it (a
little).
thought you might as well have the results since you don't have an example at
the moment.

i'm actually working on some stuff with regard to using texen to generate java
classes (to be used in ecs, as it happens).

- robert



Re: texan questions

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Robert Burrell Donkin wrote:
> 
> 1. how busy is the velocity-dev list?

'medium'

> 2. is texan currently under active development by velocity, or is the focus
> mainly on torque on the turbine list?

'texen' -  'texan' is that guy in washinton...

It's an active part of the Velocity project.  If you are referring to
the issue you raised last week, I apologize... lets do it now.... (need
to review :)

geir

-- 
Geir Magnusson Jr.                               geirm@optonline.net
Developing for the web?  See http://jakarta.apache.org/velocity/

Re: texan questions

Posted by Jon Stevens <jo...@latchkey.com>.
on 4/16/01 1:45 PM, "Robert Burrell Donkin" <Ro...@appleonline.net>
wrote:

> 1. how busy is the velocity-dev list?

Look at the archives.

> 2. is texan currently under active development by velocity, or is the focus
> mainly on torque on the turbine list?

Both. I would say that texen development questions can go to velocity-dev.

-jon


texan questions

Posted by Robert Burrell Donkin <Ro...@appleonline.net>.
1. how busy is the velocity-dev list?
2. is texan currently under active development by velocity, or is the focus
mainly on torque on the turbine list?

- robert


Re: Velocity on weblogic

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
daljeetsingh wrote:
> 
> Hello,
> 
> Well now I was able to change the default properties file and place the
> vm files in the correct place. One question still remains that where in
> weblogic 5.1 we can put these settings:
> 
> <servlet>
>   <servlet-name>MyServlet</servlet-name>
>   <servlet-class>com.foo.bar.MyServlet</servlet-class>
>   <init-param>
>       <param-name>properties</param-name>
>       <param-value>velocity.properties</param-value>
>   </init-param>
> </servlet>
> 
> In TOMCAT they go into the web.xml file. Any ideas where it goes on
> weblogic 5.1
> 

I am actually a little startled that you can't use a web.xml deployment
descriptor in WebLogic.  Reading the Servlet Spec 2.2, page 44, pte
pretty clear that

WEB-INF/web.xml

is part of the spec.

Have you tried it?  There may be some implementation issues in WebLogic,
but if you could try this, we are very interested in seeing it work for
you, and selfishly, getting this information into our documentation.

geir

-- 
Geir Magnusson Jr.                               geirm@optonline.net
Developing for the web?  See http://jakarta.apache.org/velocity/

Re: Velocity on weblogic

Posted by daljeetsingh <da...@softhome.net>.
Hello,


Well now I was able to change the default properties file and place the
vm files in the correct place. One question still remains that where in
weblogic 5.1 we can put these settings:

<servlet>
  <servlet-name>MyServlet</servlet-name>
  <servlet-class>com.foo.bar.MyServlet</servlet-class>
  <init-param>
      <param-name>properties</param-name>
      <param-value>velocity.properties</param-value>
  </init-param>
</servlet>

In TOMCAT they go into the web.xml file. Any ideas where it goes on
weblogic 5.1

Otherwise it seems to be running well.
Thanks,
Daljeet Singh 
ecExperts India 
Ph:- (O) +91-11-4670906
(R) +91-11-7125680 
ICQ:- 75129600
Yahoo:- daljeetsinghmaken 

Velocity on weblogic

Posted by daljeetsingh1 <da...@softhome.net>.
Hello,

Can anybody describe the installation procedure for velocity on weblogic
5.1 server.

The problem is where do the following things go

1. velocity.properties file
2. Templates
3. Also since there is no web.xml file where will I write the following
(from velocity user guide)
<servlet>
  <servlet-name>MyServlet</servlet-name>
  <servlet-class>com.foo.bar.MyServlet</servlet-class>
  <init-param>
      <param-name>properties</param-name>
      <param-value>velocity.properties</param-value>
  </init-param>
</servlet>



Thanks
Daljeet Singh 
ecExperts India 
Ph:- (O) +91-11-4670906
(R) +91-11-7125680 
ICQ:- 75129600
Yahoo:- daljeetsinghmaken 

Re: escape characters in #set

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Davide Mora wrote:
> 
> Hi!
> 
> i writing a template for ANT, with a lot of ${..}, and
> i found a little problem:
> 
> set ( $myvar = "\${project}")
> 
> because i want my $myvar contains "${project}" without
> be used by velocity.

#set( $myvar = '${project}')

Velocity won't interpolate values in a string literal if you use single
quotes.  Is that what you mean?

I'll take a look at the parser error, but the above I think is what you
want to do.

geir

> 
> this cause an error:
> 
> org.apache.velocity.runtime.parser.TokenMgrError:
> Lexical error at line 23, column 15.  Encountered: "$"
> (36), after : "\"\\"    at
> org.apache.velocity.runtime.parser.ParserTokenManager.getNextToken(ParserTokenManager.java:3496)
>         at
> org.apache.velocity.runtime.parser.Parser.jj_scan_token(Parser.java:3052)
>         at
> org.apache.velocity.runtime.parser.Parser.jj_3R_48(Parser.java:2320)
>         at
> org.apache.velocity.runtime.parser.Parser.jj_3R_35(Parser.java:2446)
>         at
> org.apache.velocity.runtime.parser.Parser.jj_3R_21(Parser.java:2497)
>         at
> org.apache.velocity.runtime.parser.Parser.jj_3_6(Parser.java:2895)
>         at
> org.apache.velocity.runtime.parser.Parser.jj_2_6(Parser.java:2186)
>         at
> org.apache.velocity.runtime.parser.Parser.Expression(Parser.java:1495)
>         at
> org.apache.velocity.runtime.parser.Parser.Assignment(Parser.java:1546)
>         at
> org.apache.velocity.runtime.parser.Parser.Expression(Parser.java:1496)
>         at
> org.apache.velocity.runtime.parser.Parser.SetDirective(Parser.java:1437)
>         at
> org.apache.velocity.runtime.parser.Parser.Statement(Parser.java:268)
>         at
> org.apache.velocity.runtime.parser.Parser.process(Parser.java:218)
>         at
> org.apache.velocity.runtime.parser.Parser.parse(Parser.java:78)
>         at
> org.apache.velocity.runtime.Runtime.parse(Runtime.java:584)
>         at
> org.apache.velocity.Template.process(Template.java:159)
>         at
> org.apache.velocity.runtime.resource.ResourceManager.getResource(ResourceManager.java:336)
>         at
> org.apache.velocity.runtime.Runtime.getTemplate(Runtime.java:625)
>         at
> org.apache.velocity.app.Velocity.getTemplate(Velocity.java:461)
> 
> the workaround is:
> 
> set ($usd = "\$")
> set ( $myvar = "$usd{project}")
> 
> Thank you,
> Davide
> 
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.
> http://personal.mail.yahoo.com/?.refer=text

-- 
Geir Magnusson Jr.                               geirm@optonline.net
Developing for the web?  See http://jakarta.apache.org/velocity/