Velocity

N

Nathan Hazout

Hi,
I'm a young web-programmer (I'm actually just a Student).
So far I've only been working on PHP+MySQL.

I work part time for a company, and now they want me to work on one of
their website : http://www.makemeheal.com
The thing is, I'm not sure what language to learn so that I can start
working on it.
There are no more tech guy there, and the owner is not an expert.
All he could tell me was that there is something about "Java" and
"Velocity" in it.
I looked up on the Internet,"Velocity is a Java-based template engine.
It permits anyone to use the simple yet powerful template language to
reference objects defined in Java code".

Now my question is, do I need to learn only Java? Only Velocity? Or both?

Thank you,

Nathan
 
W

Will Hartung

Nathan Hazout said:
Hi,
I'm a young web-programmer (I'm actually just a Student).
So far I've only been working on PHP+MySQL.

I work part time for a company, and now they want me to work on one of
their website : http://www.makemeheal.com
The thing is, I'm not sure what language to learn so that I can start
working on it.
There are no more tech guy there, and the owner is not an expert.
All he could tell me was that there is something about "Java" and
"Velocity" in it.
I looked up on the Internet,"Velocity is a Java-based template engine.
It permits anyone to use the simple yet powerful template language to
reference objects defined in Java code".

Now my question is, do I need to learn only Java? Only Velocity? Or both?

Both.

Velocity is used as an embedded script language within (among others things)
HTML pages, but by design it is a very limited language.

Typically you will do all of the work in Java and then use Velocity to make
simple page rendering decisions.

To move forward, not only will you need to understand Java and Velocity, but
you will also need to understand the build process that created the original
webapp. With PHP you could simply edit your pages and emebedded logic in
place and be able to see your changes With Java/Velocity, that is probably
not the case and you'll need to rebuild the webapp for any logic changes,
and perhaps for any Velocity template changes.

However, once you figure out the build process, there shouldn't be a huge
hurdle to climb for you as ideally there will be Java code that does most of
the "Web stuff" you want to do in the app already that can use for examples.

Ideally, the build process is simple and using Ant (look for a build.xml in
the project source code). That will also lessen your learning curve if
that's the case.

Hopefully, your process will be little more than:

+ Add/Change java code or Velocity templates
+ run the ant command (just type 'ant' in the directory where the build.xml
file is)
+ redeploy (hopefully with an ant command) and restart your dev server and
test.

If you can get in contact with the original app designer, that would be
ideal, as he can get you up to speed faster than anybody.

All that said, again assuming you're not doing dramatic changes to the site
and that it was reasonably well done to begin with, there's no reason you
need more than cursory knowledge about the intricacies of Java to move
forward if you can rely on the current source base as a set of working
examples and move from there.

Good Luck!

Regards,

Will Hartung
([email protected])
 
N

Nathan Hazout

Thanks,
Little question:
When you type the address of the website, it seems to load a page called
"home.do", but I couldn't find any file with that name in that directory.
Is that normal? Is this Java stuff?
Also, if you'd have a book to recommend to me ...

Thank You,

Nathan
 
S

Sudsy

Nathan said:
Thanks,
Little question:
When you type the address of the website, it seems to load a page called
"home.do", but I couldn't find any file with that name in that directory.
Is that normal? Is this Java stuff?
Also, if you'd have a book to recommend to me ...

Ooh! Are you sure it's not Struts? I only ask as the .do mapping is
common and even suggested when using Struts. A quick peek at the
application web.xml should answer the question...
 
W

Will Hartung

Nathan Hazout said:
Thanks,
Little question:
When you type the address of the website, it seems to load a page called
"home.do", but I couldn't find any file with that name in that directory.
Is that normal? Is this Java stuff?
Also, if you'd have a book to recommend to me ...

Yeah, that .do extenstion is most probably from Struts.

Struts is a very popular framework used to build websites. This is actually
a good thing for you (IMHO), as it gives you more resources to turn to, and
a structure to leverage, which means less detail to learn right away.

Here's a summary of the "things you need to know", based on what you've told
us.

Java
JDBC (assuming there's a database involved, and there probably is)
Java Servlets
JSP (perhaps)
Struts
Velocity
Ant (can't fathom somone using Stuts and not using Ant)

It sounds like they're using Velocity instead of JSP for rendering, but they
may not be 100% consistent with that and could very well have mixed
technologies.

I would most certainly try and get a book on Struts, if for nothing else
than to explain the relationship between the code, struts-config.xml, and
web.xml in your web app.

I have the book "Struts in Action", and it's a pretty good book, others may
have other suggestions.

The things you need to figure out, in order, I think are:

building the system (type ant -projecthelp to get a summary of the
build.xml)
deploying the system (it hopefully just creates a .WAR file for you to copy
to the server [probably Tomcat]. Even better if it deploys automatically.)
understanding how Struts ActionForms and Actions and JSP/Velocity interact
(at a higher level)
understand HttpServletRequest
changing an existing ActionForm
changing an existing action (home.do is a Struts action, and has a
HomeAction.java class [I imagine] someplace managing its logic).
changing an existing Velocity template
adding a new ActionForm
adding a new action
adding a new Velocity template

These are all pretty high level. You don't need an intimate understanding of
any of these technologies to actually be productive, obviously it depends on
what kind of work you need to do.

Ant, Struts, Tomcat [if you're using this as your servlet container] and
Velocity are all "documented" and available from apache.org. Start at
jakarta.apache.org and go from there.

I'm relying on the fact that you have a working system, that it was
reasonably organized using most of the practices suggested for Struts
development, and that you're not redoing the whole thing from scratch or
adding any dramatic new functionality right away. The trick is to grok the
vocabulary and rely on the in place code for examples and details. While
what you have may not be "perfect best practices" (whatever they are), it's
(apparently) functional and you should be able to use it as a bedrock for
your incremental improvements without having to be expert in any of these
new areas. If it worked for the previous coder, it will probably work for
you. As you get better and more versed in the techniques and technologies,
perhaps you can come back and replace anything you do now that "stinks
later".

Good Luck!

Regards,

Will Hartung
([email protected])
 
N

Nathan Hazout

I don't know what is Struts.

Here is what I know:
- The index.html page redirects to home.do .
- There are no *.do files in the folder, only *.vm.
- .vm files look like that : #set ($layout = "template-BlankLayout.vm")
- I just found a folder called "source" with a build.xml, and
build.properties in it, and what looks like a copy of the main folder.

Oh ... I just found a readme file that might interest you:
1. MMH web application (http://www.makemeheal.com/mmh)
mmh/src/java Java sources
mmh/webapp Images, Velocity Templates, webapp config files
(Struts, Velocity)
WARNING: All templates at AOIndustries are the
latest
mmh/javadoc Java API documentation
build.xml The build.xml Ant file
build.properties property file used by build.xml

2. FORUM web application (http://www.makemeheal.com/forum)
forum/source Java sources
mmh/webapp Images, JSP Templates, webapp config files
(WARNING: files at AOIndustries are the latest)
forum/build Folder to build application - read the README
inside

All other folders within 'forum' are used to build the forum
application.

The following are required to build the application:
1. J2SDK 1.4
2. Apache Ant

The following are referenced:
1. J2SDK 1.4 (http://java.sun.com)
2. Jakarta Struts (http://jakarta.apache.org/struts)
3. Jakarta Velocity (http://jakarta.apache.org/velocity)
4. Apache Ant (http://ant.apache.org) for building the application
5. Yazd Forum (http://yazd.yazna.com)

Knowing all of this, what do you think I should learn first ? And then?
It looks like there are a lot of stuff involved in here... There are a
lot of folders everywhere in the FTP server.

Thank you,

Nathan
 
S

Sudsy

Nathan said:
I don't know what is Struts.

Here is what I know:
- The index.html page redirects to home.do .
- There are no *.do files in the folder, only *.vm.
- .vm files look like that : #set ($layout = "template-BlankLayout.vm")
- I just found a folder called "source" with a build.xml, and
build.properties in it, and what looks like a copy of the main folder.

Knowing all of this, what do you think I should learn first ? And then?
It looks like there are a lot of stuff involved in here... There are a
lot of folders everywhere in the FTP server.

Will Hartung figured that Struts was probably involved; the README files
confirm it.
I hate to say this but you're facing a HUGE learning curve. If you were
adressing these technologies one at a time, over an extended period,
then you might be able to keep your head above water. Trying to fathom
the tecnologies listed by Will could quickly sink you.
I'm not trying to dissuade you, merely noting that it took me ages to
get truly proficient with some of these extensions. You'd better steel
yourself for a lot of 60-80 hour weeks if there's any time constraint
on these mods. There's just SO much to learn!
If I can offer a constructive piece of advice it would be to suggest
to your employer that they consider engaging the services of a
consultant already familiar with these tools. Just an idea to give you
a bit of breathing room...
 
N

Nathan Hazout

Thanks to both of you,
Sudsy : I'm gonna go step by step, see what he wants me do to first,
time is not that important for him right now.

If he asks me to go deep into java, there is something I need to know.
I looked up for 'Java' books on the web, but I know that java is also
used to make 'applets'. I don't think that's what I need to learn right?
Would sound more like 'Servlet' I think.
How to know if it's going to be the right book? Is there a different
name for 'Java servlets' ?

Thank you

Will said:
Thanks,
Little question:
When you type the address of the website, it seems to load a page called
"home.do", but I couldn't find any file with that name in that directory.
Is that normal? Is this Java stuff?
Also, if you'd have a book to recommend to me ...


Yeah, that .do extenstion is most probably from Struts.

Struts is a very popular framework used to build websites. This is actually
a good thing for you (IMHO), as it gives you more resources to turn to, and
a structure to leverage, which means less detail to learn right away.

Here's a summary of the "things you need to know", based on what you've told
us.

Java
JDBC (assuming there's a database involved, and there probably is)
Java Servlets
JSP (perhaps)
Struts
Velocity
Ant (can't fathom somone using Stuts and not using Ant)

It sounds like they're using Velocity instead of JSP for rendering, but they
may not be 100% consistent with that and could very well have mixed
technologies.

I would most certainly try and get a book on Struts, if for nothing else
than to explain the relationship between the code, struts-config.xml, and
web.xml in your web app.

I have the book "Struts in Action", and it's a pretty good book, others may
have other suggestions.

The things you need to figure out, in order, I think are:

building the system (type ant -projecthelp to get a summary of the
build.xml)
deploying the system (it hopefully just creates a .WAR file for you to copy
to the server [probably Tomcat]. Even better if it deploys automatically.)
understanding how Struts ActionForms and Actions and JSP/Velocity interact
(at a higher level)
understand HttpServletRequest
changing an existing ActionForm
changing an existing action (home.do is a Struts action, and has a
HomeAction.java class [I imagine] someplace managing its logic).
changing an existing Velocity template
adding a new ActionForm
adding a new action
adding a new Velocity template

These are all pretty high level. You don't need an intimate understanding of
any of these technologies to actually be productive, obviously it depends on
what kind of work you need to do.

Ant, Struts, Tomcat [if you're using this as your servlet container] and
Velocity are all "documented" and available from apache.org. Start at
jakarta.apache.org and go from there.

I'm relying on the fact that you have a working system, that it was
reasonably organized using most of the practices suggested for Struts
development, and that you're not redoing the whole thing from scratch or
adding any dramatic new functionality right away. The trick is to grok the
vocabulary and rely on the in place code for examples and details. While
what you have may not be "perfect best practices" (whatever they are), it's
(apparently) functional and you should be able to use it as a bedrock for
your incremental improvements without having to be expert in any of these
new areas. If it worked for the previous coder, it will probably work for
you. As you get better and more versed in the techniques and technologies,
perhaps you can come back and replace anything you do now that "stinks
later".

Good Luck!

Regards,

Will Hartung
([email protected])
 
S

Sudsy

Nathan said:
Thanks to both of you,
Sudsy : I'm gonna go step by step, see what he wants me do to first,
time is not that important for him right now.

If he asks me to go deep into java, there is something I need to know.
I looked up for 'Java' books on the web, but I know that java is also
used to make 'applets'. I don't think that's what I need to learn right?
Would sound more like 'Servlet' I think.
How to know if it's going to be the right book? Is there a different
name for 'Java servlets' ?

Well done! You've already managed to discern the difference and
correctly identified the relevant technology.
Although I haven't read it, I'm going to go out on a limb and
suggest "Java Servlet Programming" by Jason Hunter, ISBN
0-596-00040-5.
O'Reilly has a well-earned reputation in the computer book
business and many of their tomes have become "the" standard
reference ("DNS and BIND" just to name one!).
If you need to bone up on JSPs (which are compiled down to
servlets) then I can highly recommend "Advanced JavaServer
Pages" by David M. Geary, ISBN 0-13-030704-1. It's published
by Sun Microsystems Press.
Finally, if you're going to do any Struts programming at all,
you'll need what I consider to be the bible: "Programming
Jakarta Struts" by Chuck Cavaness, ISBN 0-596-00328-5.
I'm afraid that I haven't found the definitive reference for
EJB programming, although I have a couple of volumes on the
bookshelf. They're contradictory in some places, complementary
in others, so it wouldn't be fair to cite either.
It goes without saying that you need to install a LOT of
software for educational purposes. Some RDBMS and a J2EE server
(perhaps JBoss <http://www.jboss.com/>) or a servlet container
(i.e. Tomcat <http://jakarta.apache.org/tomcat/>) should be
considered mandatory. If you're doing a lot of development then
you should seriously consider installing an IDE such as Eclipse
(<http://www.eclipse.org>).
And if you're using the Eclipse/JBoss combination then you
DEFINITELY NEED jboss-ide. They have one of the best tutorials
I've seen about the effective use of Xdoclets for generating
EJBs. You can find a copy here:
<http://unc.dl.sourceforge.net/sourceforge/jboss/Tutorial-1.3.0.pdf>
It's going to take a lot of self-study to get up to speed on these
technologies but these suggestions should help you get started.
Good luck!
 
B

Bryan Castillo

Nathan Hazout said:
Thanks to both of you,
Sudsy : I'm gonna go step by step, see what he wants me do to first,
time is not that important for him right now.

If he asks me to go deep into java, there is something I need to know.
I looked up for 'Java' books on the web, but I know that java is also
used to make 'applets'. I don't think that's what I need to learn right?
Would sound more like 'Servlet' I think.
How to know if it's going to be the right book? Is there a different
name for 'Java servlets' ?

Wow you are in for a lot of work! There are a lot of tangents to hit
along the way too which might distract you. I already saw people
mentioning xdoclet and ejbs (run!). You need to know jsp and servlets
somewhat, enough to understand what they are. You need to be able to
run the web application (do you know what your employer is running the
app on for a web server? (Tomcat, Weblogic, etc.. ?)

Here is my suggestion in tackling this:
1. Learn how to start and stop the web server and validate the
application is running.
2. Learn how to build the application (using ant
http://ant.apache.org)
3. Learn how to deploy the application to the web container
(ant operates on the build.xml file and it should either create
a .war or .ear file - find out which one its creating)
b) figure out what to do with the resulting file
(In Tomcat you can usually copy a war to
$TOMCAT_HOME/webapps)
4. Learn a little bit about Struts - its a very different way to
think
about creating web pages than php. (Hint: Those .do files
are not files just urls, there is a pattern match for anything
ending
in .do to hit the Struts servlet, this servlet usually uses a
file
struts-config.xml to figure out what java class to call. When
the java class is done processing the request POST, GET
parameters,
database lookups, etc.... There will usually be a call to get
a Mapping
back and return it to the Servlet. This mapping is just
another page
to be called. Usually its a jsp page, but in your case its
going to
be a velocity template. The struts-config.xml shows what page
will
then be called.)
5. Learn velocity - I imagine that your first changes will be in the
presentation layer. Those .vm files are most likely creating
the
html. Learn how to change the html and how to get the
variables out,
etc....
6. Now try and change the velocity templates and html and deploy
your changes.


After all that (hopefully you will feel really good about yourself)
then
you can go back and really learn it all.

Basically what I'm saying is (in this order):

1. learn how to be the administrator of the application
2. learn how to make cosmetic changes.
3. finally learn how it really works.
Thank you

Will said:
Thanks,
Little question:
When you type the address of the website, it seems to load a page called
"home.do", but I couldn't find any file with that name in that directory.
Is that normal? Is this Java stuff?
Also, if you'd have a book to recommend to me ...


Yeah, that .do extenstion is most probably from Struts.

Struts is a very popular framework used to build websites. This is actually
a good thing for you (IMHO), as it gives you more resources to turn to, and
a structure to leverage, which means less detail to learn right away.

Here's a summary of the "things you need to know", based on what you've told
us.

Java
JDBC (assuming there's a database involved, and there probably is)
Java Servlets
JSP (perhaps)
Struts
Velocity
Ant (can't fathom somone using Stuts and not using Ant)

It sounds like they're using Velocity instead of JSP for rendering, but they
may not be 100% consistent with that and could very well have mixed
technologies.

I would most certainly try and get a book on Struts, if for nothing else
than to explain the relationship between the code, struts-config.xml, and
web.xml in your web app.

I have the book "Struts in Action", and it's a pretty good book, others may
have other suggestions.

The things you need to figure out, in order, I think are:

building the system (type ant -projecthelp to get a summary of the
build.xml)
deploying the system (it hopefully just creates a .WAR file for you to copy
to the server [probably Tomcat]. Even better if it deploys automatically.)
understanding how Struts ActionForms and Actions and JSP/Velocity interact
(at a higher level)
understand HttpServletRequest
changing an existing ActionForm
changing an existing action (home.do is a Struts action, and has a
HomeAction.java class [I imagine] someplace managing its logic).
changing an existing Velocity template
adding a new ActionForm
adding a new action
adding a new Velocity template

These are all pretty high level. You don't need an intimate understanding of
any of these technologies to actually be productive, obviously it depends on
what kind of work you need to do.

Ant, Struts, Tomcat [if you're using this as your servlet container] and
Velocity are all "documented" and available from apache.org. Start at
jakarta.apache.org and go from there.

I'm relying on the fact that you have a working system, that it was
reasonably organized using most of the practices suggested for Struts
development, and that you're not redoing the whole thing from scratch or
adding any dramatic new functionality right away. The trick is to grok the
vocabulary and rely on the in place code for examples and details. While
what you have may not be "perfect best practices" (whatever they are), it's
(apparently) functional and you should be able to use it as a bedrock for
your incremental improvements without having to be expert in any of these
new areas. If it worked for the previous coder, it will probably work for
you. As you get better and more versed in the techniques and technologies,
perhaps you can come back and replace anything you do now that "stinks
later".

Good Luck!

Regards,

Will Hartung
([email protected])
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top