An open source implementation of Struts, MVC implements complex large sites for this servlet and JSP framework
(Reprinted from IBM DeveloperWorks China website Java Zone, http://www-900.ibm.com/developerWorks/java/j-struts/index.shtml)
Malcolm Davis Consultant February 2001
Content: Introduction JSP is the use of too many Java MVC MVC Model 2 Struts in my HTML. Sample Sample Funds, Struts, Final Comment Reference Resources Author
This article describes Struts, which is a Model-View-Controller implementation using servlet and JavaServer Pages technology. Struts helps you control changes in the web project and improve the level of specialization. Although you may never use Struts to implement a system, you can use some of these ideas for your future servlet and JSP webpage implementation.
Introduction Primary school students can also post HTML web pages on the Internet. However, primary school students' web pages and professional development websites have quality. Web designers (or HTML developers) must understand colors, users, production processes, webline layouts, browser compatibility, image creation, and JavaScript, and more. The beautiful website needs to do a lot of work, most Java developers pay more attention to create a beautiful object interface, not the user interface. JavaServer Pages (JSP) technology provides web designers and Java developers with a link.
If you have developed a large web application, you understand the meaning of changing the word. "Model - View - Controller" (MVC) is a design pattern used to help you control changes. The MVC weakens the coupling between the business logic interface and the data interface. Struts is an MVC implementation that uses Servlet 2.2 and JSP 1.1 tags (belonging to J2EE specification) as part of the implementation. Although you may never use Struts to implement a system, you know that Struts may allow you to use some of the ideas for the JSP implementation of your later servlet.
In this article, I will discuss the advantages and disadvantages of the web page with a JSP file, which may be what you are familiar. Then I will discuss strut and explain how it controls changes in your web project and improves the level of specialization. Finally, I will re-develop this simple JSP file, I have taken into account in web designers and changes during the development process.
A JSP file is a Java Servlet JavaServer Page (JSP) file is just another way of reviewing the servlet. The concept of JSP file allows us to view Java servlet as an HTML page. JSP eliminates the annoying PRINT () statement that often appears in the Java code. The JSP file is first preprocessed as .java files, then compile to .class files. If you are using Tomcat, you can view the pre-processed .java files in the Work directory. Other containers may store .java and .class files in other locations; this location is related to the container. Figure 1 illustrates the process from the JSP file to the servlet.
Figure 1. Process from JSP files to servlet
(This is clearly different from Microsoft's Active Server Page (ASP). ISP is compiled into memory, not compiled into a separate file.) Simple independent JSP files in small JSP applications, often see data, Business logic and user interfaces are combined in a code module. In addition, applications typically include logic used to control application flow. Listing 1 and Figure 2 show a simple JSP file that allows users to join a mailing list. Listing 1. Join.JSP - a simple request and response JSP file <% @ page language = "java"%>
<% @ page import = "business.util.validation"%>
<% @ page import = "business.db.mailinglist"%>
<%
String Error = "";
String email = Request.getParameter ("email");
/ / Is there an email address?
IF (email! = null) {
// Verify input ...
IF (Business.util.Validation.issalidemail (email)) {
// Storage input ...
Try {
Business.db.mailingList.addemail (email);
} catch (exception e) {
Error = "Error adding email address to system." E;
}
IF (Error.Length () == 0) {
%>
/ / Redirect to Welcome Page ...
<%
}
} else {
/ / Set the error message and resume the web page
Error = Email "IS Not a Valid Email Address, please try again."
}
} else {
Email = "";
}
%>
hEAD>
<% = error%> font>