• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 velocity tag problem (org.apache.velocity.exception.ParseErrorException: Encountered "#end)

 
Thiyagaraja Thamilvaanan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The example given:See the difference?
 
Thiyagaraja Thamilvaanan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the exact contents of the Velocity page, the configuration of the action you're using, and the Struts 2 version.
 
Thiyagaraja Thamilvaanan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And also the index.jsp

from where i call struts2-velocity form this page...

 
Thiyagaraja Thamilvaanan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great; glad to hear it works :)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic