Velocity - Java Web Development New Technology
Keywords: Java, JSP, Servlet, Template, Template, Apache, Jakarta, Velocity Reader Requirements: Learn about Java Servlet Basic Concept
Velocity is a Java-based general template tool that comes from Jakarta.apache.org. The purpose of Apache development is to replace JSP / Struts.
JSP is a web application development technology developed by Sun, similar to PHP, and ASP. But there are many problems in JSP, making it difficult to promote, please refer to The Problems With JSP by Jason Hunter. Velocity is mainly used in the Java Servlet.
Template technology was first introduced as an additional toolkit in PHP. The aim is to solve the problems that are mixed with the common PHP code in PHP and HTML code, difficult to read, difficult to write, difficult to modify. In fact, this problem also exists in JSP / ASP. ASP is simple, introduced VB Script (the purpose of VBA's earliest design is to achieve each Office user, so super easy to learn, VB Script is similar to VBA syntax), making almost every one will learn to learn Java Script. . At the same time, there will be many people in ASP and HTML, but there are very few people with PHP and HTML, and there will be fewer people from JSP and HTML. Introducing Template in PHP, dividing HTML and PHP code into different files, will only change the php file in PHP, will only change the HTML file with HTML, and the division of labor is greatly enhanced, and the work efficiency is more easily written. Using Velocity, Java code is divided into different files with HTML code, do not learn JSP syntax. As one of the application technologies of MVC, Velocity is far more successful than JSP / Struts in Model and View code.
Please refer to my article to implement the HTML and PHP code separation using the IntegratedTemplate class in PHP4, and use the IntegratedTemplate class in PHP4 to implement the Block function.
Velocity can be used to generate dynamic web pages, SQL, PostScript files, and other text files that can be converted from templates. I used it to generate Email to send thank you letter. The difference between the Email sent to different users is the name of the username. It is easy to handle this thing with Velocity. First, use Dreamweaver to write an HTML format email.
Dear $ username,
....
The above variables are then replaced in the Java code and sent out. After the program is written, Email can also be modified with Dreamweaver without changing the Java code.
Velocity is used in the servlet, as follows:
1) Login.htm
???? User login