Improving struts with XSLT and XML

Source: Internet
Author: User
Tags html page http request resource xslt java web

Summary

Struts is an excellent framework for Java Web development. Struts is one of the Apache projects and now struts has been widely supported in the Java development community. In this article, Julien Mercay and Gilbert Bouzeid will introduce the process of struts, describe the struts framework, and finally put forward the design method of model 2x. Model 2x replaces the JSP page in the original presentation layer with XML/XSLT. Model 2x In this way more clearly divided the business logic layer and performance layer.

Body

Since the Servlet API was published, Java developers have used different technologies to develop Web applications. Web developers have recognized the benefits of Model 2. Model 2 refers to a Web development framework based on the MVC pattern. Model 2 separates the application logic layer from the presentation layer. Struts builds on Model 2, providing Java developers with a common controller servlet, as well as centralized resource configuration, resource management, and error-handling capabilities.

In this article we introduced model 2x. Model 2x can separate the logical layer from the presentation layer better. Let's start with model 1 and Model 2, and then tell how struts implements the MVC architecture, and finally show the reader how to improve on existing patterns through XML and XSLT.

Model 1

Understanding Model 1 is very important, and if you are unfamiliar with model 1 it will be difficult to understand the other architectures that we covered in the article. Model 1 is based on JSP files. The JSP takes parameters from the HTTP request, invokes the required business logic, processes the HTTP dialog, and then generates an HTML page.

A complete Model 1 project includes a set of JSP files (most of which are independent of each other), a set of required Java classes, and other components. Some of the early web development technologies such as ASP and PHP were developed using similar patterns.

Model 1 is probably the only advantage that is simple. The mix of business logic and display logic in Model 1 is not abstracted and detached in JSP pages, so it has great advantages in fast and small-scale application development. However, the development of complex projects with model 1 will inevitably lead to difficulties in project management.

Model 2, MVC, and struts/jsp

Figure 1

Figure 1 illustrates the three parts of the MVC architecture and their implementation in struts/jsp.

Controller (Controller): The most important part of struts is a common controller servlet. The controller is the entry point for each HTTP request sent to struts. The controller distributes the action after all requests have been interpreted. These action are subclasses of the struts action class. The developer is responsible for implementing them. The controller also automatically adds the parameters in the HTTP request to the form bean. The action is responsible for implementing the core business logic, such as making an EJB call, accessing the model through a Java bean. In struts, you can define an XML file to describe the mapping relationship between the request URI, the specific business logic processing, and the form component that represents the data provided by the customer. The controller is defined by this XML file.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.