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 ServletJavaserver page (jsp) file 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). Theasp is compiled into memory instead of compiling into a separate file.)
Simple stand-alone JSP files In a small JSP application, you 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) {// verification input ... if (Business.util.Validation.issalidemail (email) {// Storage Enter ... 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 ...