In today's web development, there are more and more java-based applications. Among them, servlet plays a very important role. This series of articles will introduce some tools to assist in servlet Development, so that you can choose from a variety of technologies during development.
Servlet technology is undoubtedly an excellent technology. Most java server technologies are based on servlet technology. However, this technology also has its own shortcomings. For example, the presentation layer (html code) is mixed with the code, and the reusability is not high. SUN proposed jsp technology, which is also a servlet-based technology. You can use it to embed java code in html. Jsp has taken a big step on the basis of servlet, but the pure jsp also has the shortcomings of servlet mentioned above. However, jsp + javabean + taglib can be used to solve the shortcomings mentioned above. However, jsp itself has other shortcomings. For details, refer to The article "The Problems with JSP. So people developed other servlet-based technologies. Let's first introduce Tapestry.
Introduction
Tapestry is an open-source servlet-based application framework that uses Component Object models to create dynamic and interactive web applications. A component is any html tag with the CID attribute. Jwc indicates Java Web Component. Tapestry completely isolates java code from html, making it easy to use this framework to develop large-scale applications. In addition, the developed applications are easy to maintain and upgrade. Tapestry supports localization and detailed error reports. Tapestry is mainly developed using javabean and xml technologies.
First Application
Before introducing the first application, we will first introduce the installation of Tapestry. Download the latest version from sourceforge. Decompress the package and put the jar file in the lib directory to CLASSPATH. Then, place the war file in the webapp directory of tomcat. Then, you can access its tutorial application through http: // localhost: 8080/tutorial.
An application in Tapestry consists of the following parts. We will introduce it with its own HelloWorld program as an example:
Servlet:
This is the main part of an application: servlet class, which must be a subclass of ApplicationServlet and must implement the getApplicationSpecificationPath () method. Example:
Import com. primix. tapestry .*;
Public class HelloWorldServlet extends ApplicationServlet
{
Protected String getApplicationSpecificationPath ()
{
Return "/tutorial/hello/HelloWorld. application ";
}
}
/Tutorial/hello/HelloWorld. application is an application description file.
Application Specification:
In fact, it is an xml file describing this application. There are many parameters to be set in this application. engine-class will be described below. The name attribute in page specifies the html file name, specification-path specifies the description file for this page. There can be many pages in an application, but the name of a page must be "Home", because this page is first displayed when you access your application.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.