Develop enterprise-class three-layer web applications with servlets (1)

zhaozj2021-02-11  227

Develop enterprise-class three-layer web applications with servlets (1)

Huang Wei, Shen Gangyu

With the in-depth development of web technology, the enterprise-class application system of the traditional client / server structure has gradually replaced the three-layer structure of the browser / intermediate layer / background database server. This structure has changed in the Microsoft's Windows DNA is also referred to in applications in Java technology as the core. The emergence of servlet technology has promoted the development of enterprise-class three-layer web applications with Java as core technology, which is best suited to the development of intermediate layers closely related to the web server. 1. Three-layer structural solutions using servlet technology, enterprise-level web applications, usually include three levels of web browsers, intermediate layers, and background database servers. (1) Web browser web browser is the first level in the three-layer structure, using the web browser as the client to face a unified application interface. (2) The servlet intermediate layer is the software that is running in the server, contacting the web browser and the background database server. The technique currently available to implement intermediate layers includes CGI, Java, and Servlet, etc. Since the servlet is loaded by the web server, it is developed by the Java language. It has a great progress than the CGI in terms of performance, reliability, and portability, so servlet is currently the technology that is best suited for the intermediate layer. (3) The background database server background database server is where the user stores data information, and the intermediate layer can access the background database through the ODBC (for the CGI intermediate layer) or JDBC (the servlet intermediate layer). 2. Planning a three-layer web application Examples of using a simple Web three-layer application explains how to use the servlet technology to construct the intermediate layer. Here we implements a simplest book management system. (1) The user can submit the book information to the intermediate layer via the web browser, and the book data is stored by the intermediate layer. (2) The user can query the book information through the web browser, and the book data is given to the browser display by the intermediate layer. The system is a web application that uses three-layer structure. The database server uses Microsoft Access. The intermediate layer is a servlet. The system is included in the system. * Users enter book information in the HTML page, entered the Book to the intermediate layer SERVLET; * Intermediate layer BookServlet builds a SQL statement, submits the SQL statement to the JDBC; * The background database server executes the SQL statement and returns the result to the intermediate layer BOOKSERVLET; * The middle layer BookServlet builds an HTML back to the customer according to the structure returned by the database. End browser. After the software structure of the system, we give the design planning of the entire system: * Designing the database structure is simplified, the book database only contains a table BookTable, in which the following fields are included:

Column Name Type Length Description BookName String 50 Title ISBN String 50 Book Unified Book Number

* Design Browser HTML Page Users can query books that have been entered in this page, or enter new book information. (3) Designing the intermediate layer of the intermediate BookServlet uses the intermediate layer implemented between the browser and the database server (we name it BookServlet) between the browser and the database server (we name it BookServlet), and it creates a suitable SQL statement based on the parameters passed by the browser HTML. , Submit the SQL statement to the background database server, then generate an HTML page to the browser according to the result executed by the SQL statement.

转载请注明原文地址:https://www.9cbs.com/read-3540.html

New Post(0)