Discussion on Using JSP system to develop and construct a layer-3 Management Information System

Source: Internet
Author: User
Tags mysql manual

1. Use JSP system to develop a three-layer Management Information System

Management Information System (MIS) is a system composed of people and computers that can collect, transmit, store, process and use information. With the development of science and technology and the expansion of information, enterprise informatization has become one of the effective means for enterprises to remain undefeated in the competition. MIS not only provides information and data in a timely and comprehensive manner, simplifies statistics, and provides different reports for different management levels, but also predicts future conditions based on past data. Therefore, it is particularly important to develop a management information system that takes both development efficiency and operation efficiency into account and meets the Distributed Event processing function. This article describes a method to build a three-tier Management Information System Using JSP system development.

2. Three-tier architecture of the system

System's three-tier architecture 1.

Figure 1 JAVA-based WEB application architecture

The entire management information system adopts the Browser/WEB/DataBASE three-tier architecture. The WEB Server accepts the request and executes a Java server-side applet Servlet and returns its output through the application server, so as to implement information resource interaction with the client. The database server is used to store various data used in the management information system. Data is directly input by the database management program. The system client only needs one browser. Related Personnel query, add, modify, and delete data through a browser, and manage information.

3. Design Mode of JSP System Development

The design pattern is a formal representation used by Object-Oriented programmers to solve programming problems. Currently, in most Browser/Server WEB applications, browsers directly interact with users through HTML or JSP to respond to user requests. Although intuitive, most of the data volumes used to manage information system operations are astonishing. As Code increases, JSP pages will be bloated and WEB servers will be overloaded. Therefore, the design mode based on Model View Controller MVC. Model-View-Controller is adopted on the middle layer. The Model layer is used to implement business logic, the View layer is used to display the user interface, and the Controller layer is mainly responsible for the control relationship between the View layer and the Model layer. Specifically, Servlet is used as the application controller, JSP document is used as the view, and JavaBeans are used to represent the model.

All requests are sent to the Controller Servlet, which accepts the requests and distributes them to the appropriate JSP for response based on the request information. At the same time, Servlet also generates JavaBeans instances Based on JSP requirements and outputs them to the JSP environment. JSP can call the method directly or use the custom tag of UseBean to obtain data in JAVABeans. This design mode achieves the separation between the data layer and the presentation layer, making development easier and faster. In this design mode, data transmission between different layers is 2.

Figure 2 data transmission in the MVC design mode

4. Data Access Technology

Database is the core content of the management information system. Currently, there are many WEB and database interface technologies. Among them, JDBC is an application interface for connecting Java programs and accessing databases. It consists of a group of classes and interfaces written in Java, is the Java API for executing SQL statements. In the management information system described in this article, JSP/Servlet + JDBC technology is used for data access, that is, the client does not generate database query commands, the browser on the client establishes a connection with the Web server on the intermediate layer through the URL. The WEB server is mainly responsible for receiving HTTP data requests from local or remote browsers. After receiving the request, the Servlet at the intermediate layer executes the SQL statement in the program, use the standard APIs provided by JDBC to access the database and perform corresponding operations. The Servlet then transmits the queried data to the JSP, and finally generates a standard JSP page to return the result to the requesting browser. This not only separates the client from the database server, but also improves the database access efficiency.

5. JSP System Development Instance

For better illustration

JSP/Servlet is used to construct a three-layer management information system. The author will give an example to analyze and design a product Mail Order Management Information System. This product Mail Order Management Information System uses JAVA language for server-side application development, using IBM's WEBshpere as the application server, the database management system selects SQL Server7.0, and the database interface program uses the JDBC2 interface. The entire system uses WEB-based methods to implement business processing, process control, permission control, and query of mail order businesses, such as customer management, employee management, order management, product management, warehouse management, and warehouse receiving management. statistics, printing, and other functions. The query function of the Order Management Section is analyzed in detail.

5.1 Database Design

For the order part, you need to define the order information table Db_order. The fields in the table include the order number ddbh, the customer number (khbh), the product number (sPBh), and the unit price (spdj ), order Quantity (dgsl), total price (hjzj), received amount (sdje), received date (sdrq ). To use the Db_order table in an application, you must establish a database connection. This function is implemented by SQL _data.JAVA. Some of the Code is as follows.

 
 
  1. public class SQL_data {   
  2.  
  3.  String url = "jdbc:odbc:PostOrder"; // use your hostname and port number here   
  4.  String login = "sa"; // use your login here   
  5.  String password ="zh12345"; // use your password here   
  6.  public Connection connection = null;   
  7.  public Statement st = null;   
  8.  public ResultSet rs = null;  
  9.  try  
  10.  {  
  11. Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");  
  12. conn =DriverManager.getConnection(url, user, password);  
  13.  } catch (Exception e)  
  14.  {  
  15. e.printStackTrace();  
  16.  }  
  17. }  

5.2 Middle Layer Design

In the development of the product mail order management information system, based on the MVC design pattern, combined with the actual situation of the system, we further divide the Model layer according to the division of labor. The Model layer is generally composed of many JAVABeans, which are divided into Command Beans, Data Beans, and View Beans based on their roles in the system. Command Beans are used to implement business logic, that is, to process object instances; Data Beans are used to describe and define object models abstracted from the real world; view Beans further encapsulate the processed object instances and return them to the client.

First, Command Beans obtains the information passed by Servlet, encapsulates the business information in the object instance defined by Data Beans, and processes the information according to the business logic. When you need to call the database for access operations, Command Beans uses the database interface method to perform operations on the database through the object instance and corresponding control information. After the database operation is complete, encapsulate the returned record set into an object instance of Data Beans. After some processing, encapsulate the information that needs to be returned to the interface into the View Beans defined in advance, and return the information to the interface through View Beans.

The following is part of the OrderGl. JAVA code for order query.

 
 
  1. Public class OrderGl {
  2. ......
  3. // Define the following method to query orders
  4. Public final String currentMultiQuery (
  5. JAVAx. servlet. http. HttpServletRequest request,
  6. JAVAx. servlet. http. HttpServletResponse response)
  7. Throws com. goods. exception. GoodsException
  8. {
  9. // Obtain the query information from the JSP page
  10. Com. goods. view. OrderViewView=GetView(Request, response );
  11. StringDdbh=View. GetDdbh (); // Order Number
  12.  
  13. // Generate an SQL statement
  14. StringSQLQuery="Select ddbh, khbh, sPBh, spdj, dgsl, hjzj, sdje, sdrq from db_order";
  15. // Perform the query operation
  16. Java. util. VectorVector=NewJAVA. util. Vector ();
  17. Com. goods. sjk. SQL _dataPer=NewCom. goods. sjk. SQL _data ();
  18. Try
  19. {
  20. JAVA. SQL. ResultSetRs=Per. ExecuteQuery (SQLQuery );
  21. While (rs. next ())
  22. {
  23. Com. goods. dx. Db_orderTemp=NewCom. goods. dx. Db_order ();
  24. Temp. setDdbh (rs. getString ("ddbh "));
  25. Temp. setKhbh (rs. getString ("khbh "));
  26. Temp. setSpbh (rs. getString ("sPBh "));
  27. Temp. setSpdj (rs. getString
  28.  
  29. ("Spdj "));
  30. Temp. setDgsl (rs. getString ("dgsl "));
  31. Temp. setHjzj (rs. getString ("hjzj "));
  32. Temp. setSdje (rs. getString ("sdje "));
  33. Temp. setSdrq (rs. getString ("sdrq "));
  34. Vector. addElement (temp );
  35. }
  36. Rs. close ();
  37. Per. close ();
  38. } Catch (Throwable e)
  39. {
  40. E. printStackTrace ();
  41. Per. close ();
  42. Cxyw. printErrorToWEB (request, response, e. toString ());
  43. Return e. toString ();
  44. }
  45. // Display relevant information back to the interface
  46. View. setVCt (vector );
  47. Request. setAttribute ("view", view );
  48. Return "1 ";
  49. }
  50. }

5.3 client Design

A view is part of an application that displays information to users, that is, the WEB page that the user returns to the user after sending a request. When you click "query", the order information result page ordercx. jsp is displayed based on the order number. This is done using the following syntax on the JSP page:

 
 
  1. <JSP:useBean id="view" class="com.goods.view.OrderView" scope="request" /> 
  2. <JSP:useBean id="temp" class="com.goods.dx.Db_order" scope="page" /> 

<JSP: useBean> the Action uses id and scope to discover existing objects, and then uses <% = view. getDdbh ()
And <% = temp. getDdbh () %>.

6. use JSP system to develop and build a three-layer Management Information System

This article proposes a solution for developing a WEB-based three-layer Management Information System Using JSP/Servlet technology. This solution achieves the separation of the presentation layer and the logic layer, making the system highly scalable. At the same time, it provides a complete idea and method for the development of the management information system.

  1. Three considerations for choosing a JSP website Space
  2. Analyze JSP Background File Management source code
  3. Solution to Chinese garbled JSP found in MySQL Manual
  4. JSP Chinese garbled Problem description and Solution
  5. How to call JSP to read images from the database and display them on the page

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.