Dynamic information publishing system of Guanghai Bureau website based on JSP technology.

Huangganglong

(Guangzhou Marine Geological Survey Guangzhou 5 10760)

Introduction to the first author: Huang Xu, female, born in 1974, is an engineer in the network room of the Information Institute of Guangzhou Marine Geological Survey.

This paper expounds the website dynamic information publishing system developed by our bureau based on B/S mode, and describes the basic modules and functions of the system. The system uses JavaBean component technology to integrate program code and JDBC to access Web database, and gives some key codes of the system implementation.

JavaBean, JSP B/S mode dynamic information publishing system

The Internet website of Guangzhou Marine Geological Survey was established in 2003, which is an important window to establish the image of the unit and show the latest scientific research achievements, advanced technical equipment and means of our bureau. At present, the traditional static information publishing mode of hand-made web pages is adopted in the publication of graphic information on the internet website of our bureau. This mode is inefficient and can't reflect the timeliness of dynamic information, which brings a lot of inconvenience to the audit and management of network information content. This is not conducive to the role of the website. The purpose of developing dynamic graphic information publishing system is to improve the automation degree and work efficiency of website dynamic graphic information publishing, avoid the tedious process of web page making, let people who don't know how to make web pages update the dynamic information content of the website, and facilitate information review and management.

JSP, as a mature dynamic web development technology, is a dynamic web technical standard initiated by SunMicrosystems and established by many companies. JSP technology has the following characteristics: ① adaptability to platform universality; ② Better safety; ③ Convenience of component development [1]. Considering the above factors, we adopted JSP technology in the process of developing the website dynamic information publishing system.

1 system structure mode

This system is developed based on B/S (Browser /Web Server) mode. Specifically, it adopts a three-tier architecture as shown in figure 1, including: ① presentation layer; ② Logical layer; ③ Data layer.

Among them, the presentation layer is the user interface part of the Internet dynamic information publishing system, the interactive interface to realize the logical processing results between users and applications, and the window for users to exchange information with the Internet, which is composed of browsers. The logic layer completes all the transaction logic related to the information publishing system, and the Web server is an important part of this layer. According to the request of the client, it starts the corresponding process to complete the relevant transaction processing, and sends the processing results to the client browser in the form of HTML code. The information publishing system is mainly composed of client browser, company website, information publishing system and database (Figure 2). The system uses Tomcat 5.0.28 as the JSP engine embedded in the Web server. At this level, in order to improve the execution efficiency and security [3], the connection with the database is realized through JavaBean. The data layer is composed of database server, which mainly provides data management, reading and writing database data, and can update and retrieve a large number of data to complete data storage. The database server used in this system is SQLServer2000.

Figure 1 three-tier architecture

Figure 1 three floors

Figure 2 Four parts of the information distribution system

Figure 2 Four parts of the information distribution system

2 Basic functional modules of the system

Considering the actual demand, the basic functional modules as shown in Figure 3 are designed. The following is the functional analysis of the main modules.

2. 1 system login

In the system login module, it is mainly used to check the legitimacy of the user's identity, and dynamically direct to different pages according to the user's identity, so that users with different identities have different operating rights.

2.2 news information management module

It is mainly used for users to publish, edit, view and review news information. Includes the following basic operations:

1) Level 1 menu manages the main menu displayed at the front desk.

2) The secondary menu displays the news information published by users in the background, and provides the function of allowing users to view, edit and delete the published information according to their rights.

3) Publish news and realize the functions of inputting, editing, previewing and uploading pictures of news information.

4) Auditing news allows users with auditing authority to audit and edit news information.

Fig. 3 Modules of the information distribution system

Fig. 3 Modules of the information distribution system

2.3 User Management Module

It mainly provides administrators with the basic maintenance and management of user information and news information.

1) Add User is used for administrators to add new users and set user rights.

2) View/delete users is used for administrators to manage existing users.

3) Modify User Password provides the function of allowing users to modify the initial password.

4) News statistics system can form news information release statistics table according to corresponding requirements.

3 Detailed design

3. 1 system platform construction

J2 SDK is the software development tool of Java2 and the foundation of Java application. JSP is based on Java technology, so J2 SDK must be installed before configuring JSP environment. This system uses Tomcat as JSP engine. After the software installation is completed, environment variables should be configured.

3.2 Using JDBC technology to realize database connection

Database connection is the most important part of a dynamic website. The technology of connecting database in Java is JDBC(Java Database Connectivity), which is a Java API for executing SQL. It consists of a set of classes and interfaces written in Java language, which provides a standard application programming interface for database application developers and database foreground tool developers, so that developers can write complete database applications in pure Java API language [4]. In the development, we use JavaBean to encapsulate common database operations such as database connection and SQL statement execution, which avoids the problems of huge project, long code and difficult maintenance caused by direct operation on the database. At the same time, in order to save time and resources and avoid database restart caused by traditional connection methods, we adopt database connection pool technology. The main codes are as follows:

Connection Connection = empty;

Statement stmt = null

resu 1 tset RS = null;

attempt

{

c 1 ass . forname(" com . Microsoft . JDBC . SQL server . SQL server driver "); //Load the sql driver

conn = driver manager . getconnection(" JDBC:Microsoft:SQL server://localhost: 1433; DatabaseName=gmgs ",user="root", PassWord =// Create a connection.

stmt = conn . create statement(Resultset。 Type scroll sensitive, result set. concur read _ ONLY);

string SQL = " select * from art Where id =ˊ"+id+"ˊ";

resu 1 tset RS = SQL bean . execute query(SQL); //Execute sql statement

}

conn . close(); //Return the connection to the connection pool [5]

3.3 using JavaBean to access the database

JavaBean is a kind of Java class, which becomes an object with a certain function or processing a certain business by encapsulating properties and methods. JavaBeans are organized into packages for management. In fact, a group of JavaBeans are put together in a directory, and the definition of each class is prefixed with package. Put the warp knitting file into the class in the specific directory of JSP server [6].

Using JavaBean in JSP requires the following steps:

1) defines JavaBean components, puts a group of JavaBeans together in a certain directory, and adds Package before the definition of each class to generate a. java file;

2) Compile the defined class with Javac command of JDK and generate it. Class file;

3) Call JavaBean in JSP file. The method is as follows:

Set the JavaBean to be referenced, generate an instance of JavaBean, and mark it with < < jsp:useBean > >. Instantiate a JavaBean and you can access its properties. Attribute values are obtained by using the < < jsp:getproperty > > tag, and JavaBean attribute values are changed by using the < < jsp:setproperty > > tag [7].

For example, to complete the user registration function, first define a JavaBean component named OP user.java, which adds the information filled in by the user in the form to the database table User through the add () method, and returns true if the addition is successful, otherwise it returns false. Call this JavaBean on register.jsp, a page that realizes the user registration function. The code is as follows:

< JSP:useBean id = " user " scope = " Page " class = " gmgsinfo . run . op user "/>

//instantiation

Gmgsinfo.run.op user, the identifier of this JavaBean found in the current JSP page is user.

If(user.add(request))// Use the add () method directly, and take the request object as a parameter.

3.4 Database Description

Database * * * Design five data tables.

Administrator table fields include administrator account number, password, administrator name, department, telephone number and authority.

The audit table field includes whether to audit or not.

List fields include column names.

The fields of news form include news title, column, subtitle, approver, news author, news publisher, adding time, modifying time, department, news content (including pictures) and approver.

The fields of the department table include the department name.

3.5 program description

3.5. 1 User Management

There are three main types of users of information publishing system: system administrators, auditors and ordinary maintenance personnel. The process of adding users is to enter a user name first, then call the database to make sure that the user name is not used, then fill in the user information table, set the user's initial password and authority, and finally write the user information into the database. The process of user login is that after the user submits the login form, he needs to call the database to judge whether the user's account number and password are correct. If it is correct, record the user name in the session object; If it is incorrect, return to the login interface and log in again. If the logged-in user is a system administrator, enter the administrator user interface; If it is an ordinary user, it will log in to the ordinary user interface. Users can change the initial password after logging in, and the modified information will be re-written into the database. According to the requirements of quality records, the news statistics table displays the published news in the form of a table, and users can print it directly through a printer.

3.5.2 News Information Management

The first-level menu form manages the main menu displayed on the homepage of the website. Users can add main menus that need to be displayed on the home page. The second-level menu form displays all the news released by users in the system. Including news title, release time, lower menu, news publisher, whether to approve or not. Users can click on the news headlines to preview the news, and can modify or delete their own published news. When the user clicks the modify or delete option, the system will call the user information in the database according to the user name saved in the Session object to determine whether the user has permission. If you have permission, you are allowed to modify or delete news, otherwise you will be prompted that you have no permission. In the form of news release, users only need to input information in the corresponding text box, and the system will automatically generate a web page and save the information in the database. The article content bar is a simple fckeditor, and users can edit the input news information. Users can upload pictures from the web page to the database through the upload pictures option. After news input is completed, users can preview the published news in the form of web pages. Users with approval authority in the approval news form can approve the published news, edit the news content and save it in the database again. If the news has been approved, it will be displayed on the home page of the website.

3.6 System Process Analysis

When a user logs in to the system and passes the system verification, the system will automatically save the basic information of the user and the user authority information on the server. At this time, if users have the corresponding permissions, they can manage users and permissions, manage columns, publish information, and review information.

For ordinary users, you can choose to log in to the system and do the above operation. When a user selects a module and operates it, the system will query the user rights saved in the server. After the verification is passed, the system will display the corresponding information or function page to the user, and the user can add, edit and delete the browsed content according to his own authority. If users need to publish information, they can click on the Publish News module, enter information in the corresponding title bar, and enter the content to be published in the article content bar, and the system will call the corresponding template to form a web page. Users can preview the webpage they just created by clicking OK. If the permission verification fails, it means that the user does not have the corresponding permission, and a warning message will pop up to inform the user that the operation cannot be performed. After confirming the warning message, it will not affect the user to continue other operations with permission.

When a user enters the system as an administrator, by default, the system administrator has the maximum authority to maintain and manage the system, that is, the administrator can perform operations such as user management, user role management, user authority management, information release, article management, and information review. Each user can have multiple roles, which means that each user can have multiple permissions.

4 conclusion

JSP inherits Java's object-oriented programming language ability and cross-platform advantages, and can be closely integrated with HTML. Compared with the traditional CGI program, JSP is not only easy to write and execute, but also greatly improves the execution performance of the system and improves the efficiency of information review, release and management.

refer to

[1] Ren Yan. Publish database information using JSP. Computer engineering and application, 2002,38 (7): 212 ~ 214,249.

[2] Marty Hall, Larry Brown. Servlet and JSP Core Programming (2nd Edition). Beijing: Tsinghua University Publishing House, 2004, (6)

[3] Qu Xia. Design of secure access control for database application based on JSP. Computer Development and Application, 2005,18 (6):15 ~16, 19.

[4] Sun Min. JSP connection database method. Computer knowledge and technology, 2005, 3: 2 1 ~ 22.

[5] Li Xingfeng, Wang Yizhi. Discussion on interactive technology of Web dynamic database based on JSP. Computer applications and software, 2005,22 (4): 26 ~ 27, 127.

[6] Li Yuan, Liu. JSP applications that use JavaBeans to connect to databases. 2005, 12 ( 1): 77 ~ 80.

[7] Meng, Shen Junyi. Implementation of a WEB database application security design. Computer engineering and application, 2002, 9: 1 19.

Website of Dynamic Information Publishing System of Guangzhou Marine Geological Survey Based on JSP

Huangganglong

(Guangzhou Marine Geological Survey, Guangzhou, 5 10760)

This paper introduces the dynamic information publishing system based on B/S mode designed by gmgs, and describes the basic modules and functions of the system. The system uses JaveBean technology to integrate the program code, uses JDBC to access the Web database, and gives the key code of the system implementation.

Keywords: JSP B/S mode dynamic information publishing system web JavaBean