Abstract: This article introduces a framework for developing Web-based management information systems. With JSP / Servlet technology, combine MVC design patterns to make the development process more flexible and easier to maintain.
Keywords: management information system, JSP, servlet, MVC design mode, JDBC
1 Introduction
Management Information System (MIS) is a system that makes information, transfer, storage, processing, and use, composed of people, computers. With the development of technology, the expansion of information, the company information has become one of the effective means of enterprises in the competition. MIS can not only provide information and data in time, simplify statistical work, but also put forward different reports on different management levels, and can also predict the future based on past data. Therefore, it is especially important to develop a management information system for development efficiency and operational efficiency, while meeting distributed event processing functions. This paper describes a method of constructing a three-layer management information system using JSP / servlet.
2, system three-layer architecture
The three-layer architecture of the system is shown in Figure 1.
Figure 1 WEB application architecture based on Java technology
The entire management information system uses the three-layer architecture of Browser / Web / Database. The web server accepts a request, performs a Java server-side applet servlet through the application server and returns its output to achieve interaction with the client for information resources. The database server is used to store the various data used in the management information system, and the data is accessed directly by the database management program. The system's client only needs a browser. Relevant personnel use browser to query, increase, modify, delete data, manage information. 3, system design mode
The design pattern is a formal representation of object-oriented programming designers to solve programming problems. Currently, in the web applications of most Browser / Server structures, the browser interacts with the user through the form of HTML or JSP, responding to the user's request. Although it is very intuitive, the amount of data operated by most management information systems is amazing. As the code increases, the JSP page is bloated, and the load of the web server is too heavy. Therefore, the design mode based on the model view controller (MVC.Model-View-Controller) is used on the intermediate layer. The Model layer is used to implement business logic, and the View layer is used to display the user interface, and the Controller layer is primarily responsible for the control relationship between the View layer and the Model layer. When implemented, the servlet uses as the application's controller, and the JSP document is used as a view, and JavaBeans is used to represent the model. All requests are sent to a servlet as a controller, which accepts requests and distributes them to the appropriate JSP based on request information. At the same time, servlet also generates JavaBeans instances and outputs it to the JSP environment based on JSP needs. JSP can get data in JavaBeans by direct calling methods or custom labels using UseBeans. This design pattern is well achieved with the separation of data layers and representations, making development work easier and rapid. In this design mode, data transfer between each level is shown in Figure 2.
Figure 2 Data transfer diagram of MVC design mode
4, data access technology
The database is the core content of the management information system. Currently, Web and database interface technologies have a lot, of which JDBC is an application interface for Java programs and access to the database. It consists of a set of classes and interfaces written in Java language, which is the Java API that performs SQL statements. In the management information system introduced in this article, the technology of JSP / Servlet JDBC is used in terms of access, that is, the client does not generate database query commands. The browser on the client is established through the URL and the intermediate web server. . The web server is primarily responsible for receiving an HTTP data request for a local or remote browser, and then the servlet of the intermediate layer receives the request, and the standard API provided by the JDBC will be accessed and the corresponding operation processing by the standard API provided by the JDBC by executing the SQL statement in the program. The servlet will pass the query to the JSP, and finally generate a standard JSP page to return the result to the requesting browser. In this way, not only separate the client and the database server side, but also improve the access efficiency of the database. 5, instance
In order to better illustrate the method of building a three-level management information system with JSP / servlet, the author will analyze a product mail order management information system. This product mail-order management information system uses Java language to develop server-side applications, using IBM's WebShpere as the application server, the database management system selection SQL Server 7.0, the database interface program uses JDBC2 interface. The entire system uses web-based ways to implement customer management, staff management, order management, product management, outbrace management, library management, and other functions such as mail delivery service, process control, permission control, query statistics and printing. The query function of the order management section is analyzed in detail.
5.1 Database Design
For the order section, you need to define the order information table DB_ORDER, the fields in the table include order number (DDBH), customer number (SPBH), commodity unit price (SPDJ), order quantity (DGSL), total total price ( HJZJ), received the amount (SDJE), received the date (SDRQ). In order to be able to use the DB_ORDER table in the application, a database connection must be established. This feature is implemented by SQL_DATA.java. Some of the code is as follows.
Public class sql_data {
String url = "jdbc: odbc: PostOrder"; // use your hostname and port number here String login = "sa"; // use your login here String password = "zh12345"; // use your password here public Connection connection = null; public Statement st = null; public ResultSet rs = null; try {Class.forName ( "com.microsoft.jdbc.sqlserver.SqlServerDriver"); conn = DriverManager.getConnection (url, user, password);} catch (Exception e) {E.PrintStackTrace ();}}
5.2 Intermediate layer design
During the development of the merchandise mail order management information system, based on the idea of MVC design model, combined with the actual situation of the system, we divide the Model layer according to division. The Model layer is generally composed of many Javabeans, which divides them into three types of Command Beans, Data Beans, View Beans, based on these Beans in the system. The Command Beans is used to implement the processing of the business logic, which is the object of object instances; Data Beans is used to describe and define abstract object models from the real world; and View Beans is used to further package the handled object instance and return Go to the client. First, Command Beans gets the information passed from the servlet and packages these business information in the object instance defined by the Data Beans, and processes the information according to the service logic. When the access operation of calling the database is required, Command Beans complete the object instance and the corresponding control information through the database interface method through the database interface method. After the database operation is completed, the returned recordset is encapsulated into the object instance of the Data Beans. After a certain process, the information returned to the interface is then sealed to the predefined View Beans, and the information returns the information via View Beans. On the interface.
The following is some of the code of Ordergl.java for querying the order.
public class OrderGl {...... // following method is defined query completion of the order public final String currentMultiQuery (javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws com.goods.exception.GoodsException { // Get the corresponding query information from the JSP page com.goods.view.orderview view = getView (request, response); string ddbh = view.getddbh (); // order number
/ / Generate SQL Statement String SqlQuery = "SELECT DDBH, KHBH, SPBH, SPDJ, DGSL, HJZJ, SDJE, SDRQ from DB_ORDER"; // Execute Query Java.util.Vector Vector = New Java.util.Vector (); com.goods.sjk.sql_data per = new com.goods.sjk.sql_data (); try {java.sql.resultSet RS = per.executeQuery (sqlQuery); while (rs.next ()) {com.goods.dx .Db_order temp = new com.goods.dx.db_order (); temp.setddbh (rs.getstring ("ddbh")); Temp.setkhbh (Rs.getstring ("khbh")); TEMP.STSPBH (RS.GetString ("SPBH")); Temp.setSpdj (Rs.getstring ("SPDJ")); Temp.SetDGSL (Rs.getstring ("DGSL")); Temp.Sethjzj (Rs.getstring ("hjzj"); TEMP .setsdje (Rs.getstring ("sdje")); Temp.setsdrq (Rs.getstring ("SDRQ")); Vector.Addelement (TEMP);}}}}} rclose (); per.close ();} catch Throwable e) {E.PrintStackTrace (); per.close (); cxyw.printerRorterToweb (Request, Response, E.TOSTRING ()); Return E.TOSTRING ();} // returns related information to the interface view. SetVCT (Vector); Request.setttribute ("View", View); Return "1";}} 5.3 Client Design
The view is part of the application to the user display information, that is, the web page that is returned to the user after the user issues a request. When you click the Query button, the order information result page obtained according to the order number will be displayed Ordercx.jsp. This is done by using the JSP page:
6, small knot
This paper proposes a solution for developing a three-layer management information system based on JSP / servlet technology. The solution achieves separation of layers and logic layers, making the system have good scalability, while providing a complete idea and approach to the development of the management information system.
Transfer from: Dynamic Network Production Guide www.knowsky.com