LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-24-2005, 03:03 PM   #1
Hockeyfan
Member
 
Registered: May 2004
Distribution: SuSe 10.0
Posts: 154

Rep: Reputation: 30
need help to understand Apache Velocity


Hello,

Here Is my thing. I am trying to develop a very simple program that implements both strus and Velocity. I am using strus to handle moving from page to page. Anyway, I have been trying to figure out how to wrrite the java code for the velocity pages. I understand the concept and the "template" of what needs to into each class to get the .vm file to be outputted as a html file. In the books that I have been reading each velocity java page I've seen in books and on the web had the velocity page have a main method. Now if I have to create a java file for each .vm file I create, which I have no problem with, I can't have a main method for each. I know that. So, how do I it? I am not sure if I should be extending from the VelocityServlet class and I am not sure about the method names. Can I mmakeup my own or should I be overwritting a predefined method?

Thanks,

Hockeyfan
 
Old 05-24-2005, 04:18 PM   #2
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
Hi,
If you wish to use Apache Velocity and Struts, there is a velstruts tool which integrates Velocity which Struts(see the velocity page).
If you want to use the original Struts and Velocity, you can edit your web.xml file and add a servlet mapping for the extension *.vm so that it will be handled by the Velocity Servlet.
 
Old 05-24-2005, 05:12 PM   #3
Hockeyfan
Member
 
Registered: May 2004
Distribution: SuSe 10.0
Posts: 154

Original Poster
Rep: Reputation: 30
I have edited my web.xml file to include the .vm file extension. What I am having trouble wrapping my head around is that I know that each .vm file that has Velocity statements needs a corresponding java file to create a true html document. My problem is that I don't know how to write the code without it being in the main method. I can't find any source code that shows me that. Unless the class I am writing is an extension of VelocityServlet and the method and in that case the method that is used is handlerequest(...). I am not used to writing java programs that are web based. I am learning but its slow. So if anyonce can help that would be great.
 
Old 05-24-2005, 06:22 PM   #4
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
You don't need a java file for every vm file, the servlet mapping and the velocityservlet exist for that purpose.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Via Velocity Network card atlantean Linux - Networking 0 11-18-2005 09:42 PM
install apache velocity nasht Linux - Enterprise 1 08-28-2005 12:22 PM
install apache velocity nasht Linux - Software 0 08-24-2005 05:36 PM
Help with understand Apache Virtual Server kitek Linux - Software 1 06-24-2005 11:28 AM
need help compiling Apache Velocity Hockeyfan Programming 3 05-25-2005 06:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration