Author
Struts2 velocity tag problem (org.apache.velocity.exception.ParseErrorException: Encountered "#end)
Thiyagaraja Thamilvaanan
Greenhorn
Joined: Aug 28, 2009
Posts: 11
Hi all,
I am trying a very simple struts2 (2.1.6) application using velocity (1.6.2 and tools 2.0 beta4) ,
It's nothing more than a simple form with a single textfield.
The code follows
when I call this velocity file I get the following error
It seems the problem is near
#end
tag ,
but I don't know how to solve this,
waiting for your reply..
regards
T.Thamilvaanan
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Sep 06, 2009 12:07:55
0
I'm not overly-familiar with the Velocity support, but it seems like you're using a random syntax.
http://struts.apache.org/2.x/docs/velocity-tags.html
Thiyagaraja Thamilvaanan
Greenhorn
Joined: Aug 28, 2009
Posts: 11
Thanks for reply ,David,
ya
Before writing my code I refered that page.
They mentioed there as
Some VM tags require an #end statement while others do not. The inconsistency arises from a limitation in Velocity where tags must declare if they are a block or inline tag up front. As such, by default all tags are inline except for a few key ones, such as the form tag.
So obviouly I need #end tag ,and I also tried without that, then the tags were just ignored and printed as it is.
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Sep 06, 2009 15:22:36
0
You're using dollar signs--that's Velocity-speak for variables, not tags. Try following the syntax from the doc page, which uses number/pound signs, "#".
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Sep 06, 2009 15:23:38
0
The example given:See the difference?
Thiyagaraja Thamilvaanan
Greenhorn
Joined: Aug 28, 2009
Posts: 11
Thanks David,
Its a grate mistake I made........
I made the changes ...........and tried again..........
But the result is same as it is before...................
Wating.................
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Sep 06, 2009 16:26:17
0
Post the exact contents of the Velocity page, the configuration of the action you're using, and the Struts 2 version.
Thiyagaraja Thamilvaanan
Greenhorn
Joined: Aug 28, 2009
Posts: 11
The web.xml
The struts2 form
The struts.xml
I am using
Apache Tomcat/6.0.20
J.D.K 1.6.0_14
Struts 2.1.6
Velocity 1.6.2 and velocity-tools-2.0-beta4
..................................................................
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Sep 06, 2009 16:41:43
0
And you're reaching that page through the action via a method that returns the string "SUCCESS" (which is not the default, btw)?
Thiyagaraja Thamilvaanan
Greenhorn
Joined: Aug 28, 2009
Posts: 11
And also the index.jsp
from where i call struts2-velocity form this page...
Thiyagaraja Thamilvaanan
Greenhorn
Joined: Aug 28, 2009
Posts: 11
Acually David,
I am calling the struts2-velocity page from index.jsp.....
And getting the error when I call........
i.e. no anyother actions involed in this application.........
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Sep 06, 2009 16:48:45
0
I don't believe that will work, but I could be mistaken.
As far as I know for the Struts 2 tags to work the page would have to be reached via an action.
Thiyagaraja Thamilvaanan
Greenhorn
Joined: Aug 28, 2009
Posts: 11
ohhhh..........
this is a new news for me ..............
...this may be the case.............
I try to call this page form an action......................
Really coundnt belive this rule .......
Ok David
I try and let you know again
Thanks
Thiyagaraja Thamilvaanan
Greenhorn
Joined: Aug 28, 2009
Posts: 11
Yes David,
you are right and genious........
I could call the same program through an action and its displayed properly...........
Thanks
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Sep 06, 2009 20:22:05
0
Great; glad to hear it works :)
subject: Struts2 velocity tag problem (org.apache.velocity.exception.ParseErrorException: Encountered "#end)