Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

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

 
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
 
Author
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
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
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
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
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
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great; glad to hear it works :)
 
I am going to test your electrical conductivity with this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!