Design and implementation of a platform for reporting bad information on the Internet based on JavaWeb

1 Introduction

With the rapid development of the Internet, the problem of bad information on the Internet has become increasingly prominent, which has brought serious troubles to people's lives and social order. Bad information on the Internet includes pornography, violence, gambling, fraud and other bad content. The dissemination of such information has a negative impact on the physical and mental health of young people, and also destroys the good order and morality of society. Facing this problem, it is imminent to establish an efficient and convenient platform for reporting bad information on the Internet.

This project aims to build a network bad information reporting platform based on JavaWeb technology to provide a safe, fast and anonymous reporting channel for netizens to report illegal and bad information. Through this platform, users can submit bad information reporting materials, including text, pictures, audio and video, etc., and can provide detailed descriptions and relevant clues for bad information. The system will automatically perform preliminary screening and classification of the submitted information, and then communicate the information to relevant law enforcement agencies or regulatory authorities for processing.

In short, this project aims to establish a platform for reporting bad information on the Internet based on JavaWeb. By providing a safe, fast, and anonymous reporting channel, it can help users discover and report bad information on the Internet in a timely manner, purify the network space, and maintain social order. Through social design, users are encouraged to transfer information to each other, forming a community of mutual participation, and jointly creating a green and healthy network environment.

2. Development technology

2.1 Introduction to JSP

The web application program developed by JSP technology is based on Java. It has the characteristics of Java cross-platform, as well as business code separation, component reuse, basic Java servlet function and pre-compilation function. It has the following characteristics: 

The working principle of JSP is that when the user's browser requests a JSP file from the WEB server, the WEB server responds to the HTTP request, the JSP engine interprets the JSP logo and small script, and uses JDBC technology to access the database to generate the requested content by accessing the Java Bean component. And the result is returned to the browser in the form of Htm1 or XML page.

Servlet provides a simple and consistent mechanism for Web developers to extend the functions of the web server and interact with existing business systems. Servlet can be regarded as an Applet running on the server side. A Java Bean is a "class" that becomes an object with certain functions or processing a certain business by encapsulating properties and methods. JavaBeans are organized into Packages for management. In fact, a group of Java Beans are placed together in the XX directory with package XX before the definition of each class. They must be placed in the directory included in the system environment CLASS PATH, and the system can find them. The Java Bean. JSP technology is an extension of servlet technology and provides support for HTML and XML page creation. Web designers can easily combine fixed or static template data with dynamic content.

2.2 Overview of B/S structure

The B/S structure is a network structure model after the rise of the Web. It is an architecture in which the browser and the server interact, and its operation mechanism is as follows. First, the browser sends a request to the browser through the domain name and URL. After the browser accepts the request, it starts to parse the URL to locate the module file, generates an HTML file according to the parameters in the URL and the module file, and sends the generated HTML file to the browser. Accept the response HTML document, parse and organize related resource files, and then display the page, a complete process is like this. The B/S is built on the WAN, and generally only needs to have an operating system and a browser, and it is aimed at unknown user groups. The ability to control security is relatively weak, but its access speed is relatively fast, and it needs to be continuously optimized. Its components are independent and perform their own duties. Each part can play an important role. Replacing individual components can make The system is upgraded seamlessly. The cost of system maintenance expenses is minimized, and users can upgrade by downloading and installing from the Internet. B/S is built on the browser, and has richer and more vivid expressions to communicate with users, and most of them are very difficult, reducing development costs.

2.3 Introduction to Servlets

Servlet (Server Applet) is the abbreviation of Java Servlet, which is called a small service program or a service connector. It is a server -side program  written in Java and has the characteristics of being independent of platforms and protocols . Dynamic web content. A servlet is a class in the Java programming language that is used to extend the capabilities of servers hosting applications that can be accessed through a "request-response" programming model. Although servlets can respond to any type of request, they are typically used only to extend Web server applications.

2.4 Introduction to MYSQL

The database is a must for the project as a data storage place. MySQL is a very good relational database. The early mysql was not owned by Oracle, but was acquired by him later. Mysql is very small, the installation package is only a few megabytes, and the writing of sql language is relatively easy to learn. The most important thing is that mysql is also an open source software, so there is no need to pay extra. The system itself also summarizes the knowledge learned by learning Mainly, in the development of the system, it is best to use free software as much as possible, so choose mysql for database management. The capacity of Mysql is also very large. At the same time, it supports the operation of sub-database and sub-table, and supports distribution. Therefore, more and more small and medium-sized enterprises choose this database management tool. It is also worth mentioning that open source also has a disadvantage, that is, it is easy to be cracked and hacked, so the use of mysql is still mainly concentrated in small and medium-sized enterprises.

2.5 JavaScript

As a dynamically compiled scripting language, the advantages of JavaScript are needless to say. With the birth of web development came a variety of development techniques. In order to survive in the big environment, JavaScript has also begun to adapt to the non-browser environment. Like Java, JavaScript can also be object-oriented, which can help students who have learned Java language learn JavaScript. In addition, JavaScript can be combined with CSS to produce many interesting page effects, which is the main reason why JavaScript is still popular in the general environment.

2.6  Tomcat server

Tomcat can be used after simple configuration on development tools (such as IDEA, Eclipse). The main reason for using the tomcat server is that first of all, it is an open source software, and no additional payment is required. You can easily download its source code and documents on Apache's official website, which is very convenient. Secondly, tomcat is very small. Because the development and operation of the system have high requirements for computer configuration, otherwise it is very easy to cause a freeze phenomenon. Therefore, in the selection of third-party software, it will be better to use smaller software as much as possible. So tomcat is also very suitable from this point of view.

2.7  Eclipse development tools

Eclipse is an open source , Java -based extensible development platform. By itself, it is just a framework and a set of services for building a development environment through plug-in components , but Eclipse comes with a standard set of plug-ins, including Java development tools (Java Development Kit, JDK ). Because it allows them to build tools that integrate seamlessly with the Eclipse environment. Since most of Eclipse is provided by plug-ins, it can provide users with a consistent and unified integrated development environment. Choose him to be portable, convenient and quick to build projects.

3. Detailed system design

The illegal and bad information reporting platform is divided into an administrator system and a user login system according to business content. The module design of the system is based on the requirements specification and system architecture, through refining the architecture, analyzing the use cases, and designing modules to identify the design elements, discover the behavior details of the design elements, and refine the definition of the design elements to ensure that the use cases achieve overall is up to date.

3.1 User module design

The user module is mainly for user registration; user login; illegal information reporting and filling; personal information modification; password modification; my record viewing. The following is a detailed description of these functions, selecting representative functions:

3.1.1 User login

Classes and JSP files involved in user login, including cuslogin.jsp (view layer), LoginUserServlet (control layer), UserService (business logic layer), UserDao (data access layer) and User (entity layer), as shown in Figure 3-1 shown.

Figure 3-1 User login business diagram

(1)login.jsp

The action (userlogin) of cuslogin.jsp is responsible for processing the user's login event, calling the doPost() method in the LoginUserServlet class, and encapsulating the user's login input information into the entity User, and calling the UserService class in the doPost() method Logical processing method login(User user).

(2) UserService class

The login(User user) method in the UserService class is responsible for the business logic of judging whether the user name and password are correct, and calls the login(User user) method in the UserDao class.

(3) UserDao class

The login(User user) method in the UserDao class is responsible for executing the "select * from suser where cusname=? and password=?" statement in the mysql database to determine whether the user name and password are correct.

(4) User class

The User class realizes the object-oriented processing of the suser table in the database and realizes the encapsulation of data.

3.1.2 User registration

The classes and JSP files involved in user registration include cusregister.jsp (view layer), RegisterUserServlet (control layer), UserService (business logic layer), UserDao (data access layer) and User (entity layer), as shown in Figure 3-2 shown.

Figure 3-2 User registration business diagram

(1)cusregister.jsp

The action (userregister) of cusregister.jsp is responsible for processing the user’s registration event, calls the doPost() method in the RegisterUserServlet class, and encapsulates the user’s registration input information into the entity User, and calls the UserService class in the doPost() method Logical processing method insert(User user).

(2) UserService class

The insert(User user) method in the UserService class is responsible for processing the business logic of user registration, calling the insert(User user) method in the UserDao class.

(3) UserDao class

The insert(User user) method in the UserDao class is responsible for executing "INSERT INTO suser (cusName, realName, phone, email, idcard, sex, province, city, address, password, status) VALUES(?,?,? ,?,?,?,?,?,?,?,?)" statement to store the information entered by the user registration.

(4) User class

The User class realizes the object-oriented processing of the suser table in the database and realizes the encapsulation of data.

3.1.3 Illegal information reporting module

Classes and JSP files involved in user illegal information reporting, including cusindex.jsp (view layer), CusSubmitInfoServlet (control layer), InfoService (business logic layer), InfoDao (data access layer) and Info (entity layer), as shown in Figure 3 -3 shown.

Figure 3-3 Business map of user illegal information reporting

(1)cusindex.jsp

The action (cussubmitsave) of cusindex.jsp is responsible for processing the user’s illegal information reporting and saving event, calling the doPost() method in the CusSubmitInfoServlet class, and encapsulating the illegal and criminal information entered by the user into the entity Info, and calling it in the doPost() method The logic processing method insert(Info info) in the InfoService class.

(2) InfoService class

The insert(Info info) method in the InfoService class is responsible for processing the business logic of reporting the illegal information filled in by the user, and calls the insert(Info info) method in the InfoDao class.

(3) InfoDao class

The insert (Info info) method in the InfoDao class is responsible for executing "INSERT INTO info (cusName, eventName, eventTime, eventPlace, eventType, pic, submitTime, flag, param1, param2, param3) VALUES (?, ?, ? , ?, ?, ?, ?, ?, ?, ?, ?)" statement to store the reported information.

(4) Info class

The Info class implements the object-oriented processing of the info table in the database and realizes the encapsulation of data.

3.1.4 User personal information modification module

Classes and JSP files involved in user personal information modification, including cusindex.jsp (view layer), UserAddServlet (control layer), UserService (business logic layer), UserDao (data access layer) and User (entity layer), as shown in Figure 3 -4 shown.

Figure 3-4 User personal information modification business diagram

 (1)cusindex.jsp

The action (usersave) of cusindex.jsp is responsible for processing the user's personal information modification event, calling the doPost() method in the UserAddServlet class, and encapsulating the user's modified personal information into the entity User, and calling UserService in the doPost() method The logical processing method update(User user) in the class.

(2) UserService class

The update(User user) method in the UserService class is responsible for processing the business logic of user personal information modification, and calls the update(User user) method in the UserDao class.

(3) UserDao class

The insert(User user) method in the UserDao class is responsible for executing "update suser set cusName=?,realName=?,phone=?,email=?,idcard=?,sex=?,province=?,city= ?,address=?,password=?,status=? where id=?”statement, update the information entered by the user.

(4) User class

The User class realizes the object-oriented processing of the suser table in the database and realizes the encapsulation of data.

3.1.5 My record viewing module

The classes and JSP files involved in my record viewing include cusindex.jsp (view layer), CusSubmitInfoServlet (control layer), InfoService (business logic layer), InfoDao (data access layer) and Info (entity layer), as shown in Figure 3 -5 shown.

Figure 3-5 My record viewing business graph

 (1)cusindex.jsp

The href(/waitinfolist?flag=0) of cusindex.jsp is responsible for processing the user’s reported pending audit records, calling the doPost() method in the InfoListWaitServlet class, and encapsulating the state value of the illegal and criminal information carried into the entity Info , and at the same time call the logic processing method selectAllInfos(Info info) in the InfoService class in the doPost() method.

(2) InfoService class

The selectAllInfos(Info info) method in the InfoService class is responsible for processing the business logic for users to query personal reporting records, and calls the selectAllInfos(Info info) method in the InfoDao class.

(3) InfoDao class

The selectAllInfos(Info info) method in the InfoDao class is responsible for executing the "select * from info where 1=1 and cusname =? and flag=?" statement in the mysql database to query and encapsulate the required records.

(4) Info class

The Info class implements the object-oriented processing of the info table in the database and realizes the encapsulation of data.

3.2 Administrator module design

The administrator module is mainly for administrator login; management of administrators, that is, query, add, modify and delete; management of user information, that is, delete, query, modify user information functions and user disable management; management of categories, That is to add, delete, change, and query functions; the management of report information review, that is, review and query functions; the management of report information processing, that is, the processing result record and query functions; the function of exporting report information.

The following is a detailed description of these functions, selecting representative functions:

3.2.1 Administrator login function

The classes and JSP files involved in administrator login include login.jsp (view layer), LoginServlet (control layer), AdminService (business logic layer), AdminDao (data access layer) and Admin (entity layer), as shown in Figure 3- 6.

Figure 3-6 Administrator login business diagram

 (1)login.jsp

The action (login) of login.jsp is responsible for processing the login event of the administrator, calling the doPost() method in the LoginServlet class, and encapsulating the login input information of the administrator into the entity Admin, and calling the AdminService class in the doPost() method The logical processing method in login(Admin admin).

(2) AdminService class

The login(Admin admin) method in the AdminService class is responsible for the business logic of judging whether the user name and password are correct, and calls the login(Admin admin) method in the AdminDao class.

(3) AdminDao class

The login (Admin admin) method in the AdminDao class is responsible for executing the "select * from admin where username=? and password=?" statement in the mysql database to determine whether the username and password are correct.

(4) Admin class

The Admin class implements the object-oriented processing of the admin table in the database and realizes the encapsulation of data.

3.2.2 New administrator function

The classes and JSP files involved in the new administrator function include add.jsp (view layer), AdminAddServlet (control layer), AdminService (business logic layer), AdminDao (data access layer) and Admin (entity layer), as shown in the figure 3-7 shown.

 Figure 3-7 The administrator adds a business map

(1)add.jsp

The action (adminsave) of add.jsp is responsible for processing the new administrator event, calls the doPost() method in the AdminAddServlet class, and encapsulates the information entered by the administrator’s new page into the entity Admin, and calls it in the doPost() method The logical processing method insert(Admin admin) in the AdminService class.

(2) AdminService class

The insert(Admin admin) method in the AdminService class is responsible for processing the business logic added by the administrator, and calls the insert(Admin admin) method in the AdminDao class.

(3) AdminDao class

The insert(Admin admin) method in the AdminDao class is responsible for executing "INSERT INTO admin(username,password,realname,sex,phone,idcard,province,city) VALUES(?,?,?,?,?,? ,?,?)" statement to save the newly added administrator information to the database.

(4) Admin class

The Admin class implements the object-oriented processing of the admin table in the database and realizes the encapsulation of data.

3.2.3 Query administrator information function

The classes and JSP files involved in querying administrator information include list.jsp (view layer), AdminListServlet (control layer), AdminService (business logic layer), AdminDao (data access layer) and Admin (entity layer), as shown in the figure 3-8 shown.

 Figure 3-8 Query administrator business diagram

(1)list.jsp

The action (adminlist) of list.jsp is responsible for processing the administrator's query event, calling the doPost() method in the AdminListServlet class, and encapsulating the query condition information into the entity Admin, and calling the logic in the AdminService class in the doPost() method The processing method is selectAllAdmin(Admin admin).

(2) AdminService class

The selectAllAdmin(Admin admin) method in the AdminService class is responsible for processing the business logic of querying administrators, and calls the selectAllAdmin(Admin admin) method in the AdminDao class.

(3) AdminDao class

The selectAllAdmin(Admin admin) method in the AdminDao class is responsible for executing the "select * from admin where 1=1" statement in the mysql database to query the list of administrator information.

(4) Admin class

The Admin class implements the object-oriented processing of the admin table in the database and realizes the encapsulation of data.

3.2.4 Delete administrator function

The classes and JSP files involved in the delete administrator information function include list.jsp (view layer), AdminDeleteServlet (control layer), AdminService (business logic layer), AdminDao (data access layer) and Admin (entity layer), as shown in the figure 3-9 shown.

Figure 3-9 Deleting the administrator business diagram 

(1)list.jsp

The a tag (admindelete) of list.jsp is responsible for processing the deletion event of the administrator, calling the doPost() method in the AdminDeleteServlet class, and encapsulating the deletion condition information into the entity Admin, and calling the AdminService class in the doPost() method Logical processing method delete(Admin admin).

(2) AdminService class

The delete(Admin admin) method in the AdminService class is responsible for processing the business logic of deleting administrators, and calls the delete(Admin admin) method in the AdminDao class.

(3) AdminDao class

The delete(Admin admin) method in the AdminDao class is responsible for executing the "delete from admin where id=?" statement in the mysql database to delete administrator information.

(4) Admin class

The Admin class implements the object-oriented processing of the admin table in the database and realizes the encapsulation of data.

3.2.5 Modify administrator information function

The classes and JSP files involved in modifying the administrator information function include add.jsp (view layer), AdminAddServlet (control layer), AdminService (business logic layer), AdminDao (data access layer) and Admin (entity layer), as shown in the figure 3-10 shown.

 Figure 3-10 Modify the administrator business map

(1)add.jsp

The action (adminsave) of add.jsp is responsible for processing the modification event of the administrator, calling the doPost() method in the AdminAddServlet class, and encapsulating the modified administrator information into the entity Admin, and calling the AdminService class in the doPost() method The logical processing method update(Admin admin).

(2) AdminService class

The update(Admin admin) method in the AdminService class is responsible for processing and modifying the business logic of the administrator, and calls the update(Admin admin) method in the AdminDao class.

(3) AdminDao class

The update(Admin admin) method in the AdminDao class is responsible for executing "UPDATE admin SET username=?,password=?,realname=?,sex=?,phone=?,idcard=?,province=?,city= ? WHERE id=?” statement to modify the administrator information.

(4) Admin class

The Admin class implements the object-oriented processing of the admin table in the database and realizes the encapsulation of data.

3.2.6 Reporting information review and approval function

The classes and JSP files involved in the report information review and approval function include list.jsp (view layer), InfoPassServlet (control layer), InfoService (business logic layer), InfoDao (data access layer) and Info (entity layer), as shown in the figure 3-11 shown.

Figure 3-11 Reported information audit passed business diagram

 (1)list.jsp

The a tag (infopass) of list.jsp is responsible for processing the event of passing the audit of the report information, calling the doPost() method in the InfoPassServlet class, and encapsulating the approved information into the entity Info, and calling the InfoService class in the doPost() method The logical processing method in update(Info info).

(2) InfoService class

The update(Info info) method in the InfoService class is responsible for processing the approved business logic, calling the update(Info info) method in the InfoDao class.

(3) InfoDao class

The update(Info info) method in the InfoDao class is responsible for executing "update info set cusName=?, eventName=?, eventTime=?, eventPlace=?, eventType=?, pic=?, submitTime=?, flag= ?,param1=?,param2=?,param3=? where id=?” statement to modify the status of the reported information.

(4) Info class

The Info class implements the object-oriented processing of the info table in the database and realizes the encapsulation of data.

3.2.7  Function of Reporting Information Review Failure

The classes and JSP files involved in the report information review failure function include check.jsp (view layer), RecordSaveServlet (control layer), InfoService (business logic layer), InfoDao (data access layer) and Info (entity layer), as shown in the figure 3-12 shown.

Figure 3-12 Business diagram of report information audit failure

(1)check.jsp

The action (recordsave) of check.jsp is responsible for handling the event of reported information audit failure, calling the doPost() method in the RecordSaveServlet class, and encapsulating the audit failure information into the entity Info, and calling the InfoService class in the doPost() method The logical processing method update(Info info).

(2) InfoService class

The update(Info info) method in the InfoService class is responsible for processing the business logic of audit failures, calling the update(Info info) method in the InfoDao class.

(3) InfoDao class

The update(Info info) method in the InfoDao class is responsible for executing "update info set cusName=?, eventName=?, eventTime=?, eventPlace=?, eventType=?, pic=?, submitTime=?, flag= ?,param1=?,param2=?,param3=? where id=?” statement to modify the status of the reported information.

(4) Info class

The Info class implements the object-oriented processing of the info table in the database and realizes the encapsulation of data.

3.2.8 Report information export function

The classes and JSP files involved in the report information export function include list.jsp (view layer), DataExportServlet (control layer), InfoService (business logic layer), InfoDao (data access layer) and Info (entity layer), as shown in Figure 3 -13 shown.

 Figure 3-13 Report information export function business diagram

(1)list.jsp

The action (exportdata) of list.jsp is responsible for processing the event of reporting information export, calling the doPost() method in the DataExportServlet class, and calling the logic processing method selectAllInfos(Info info) in the InfoService class in the doPost() method.

(2) InfoService class

The selectAllInfos(Info info) method in the InfoService class is responsible for processing the business logic of reporting information export, calling the selectAllInfos(Info info) method in the InfoDao class.

(3) InfoDao class

The selectAllInfos(Info info) method in the InfoDao class is responsible for executing the "select * from info" statement in the mysql database to query all the data that needs to be exported.

(4) Info class

The Info class implements the object-oriented processing of the info table in the database and realizes the encapsulation of data.

4. Database design

4.1 Logic Design

Database logic design is divided into three stages, namely: user requirements, establishment of ER model and database schema design.

The first stage in the database logic design is to collect and analyze user requirements in the following four steps: analyze user activities, determine the scope of the system, analyze data involved in user activities, and analyze system data. The second stage of logical design is to establish the ER model in two steps. First, the design of the local ER model should be carried out, and then the design of the overall ER model should be carried out. The third stage of logical design is divided into two steps in the database schema design stage. The first step is preliminary design, which converts the ER diagram into a relational model, and the second step is optimization design, which adjusts and improves the schema.

What we want to study is the third step of logical design, which is to transform the ER image relational model. The following converts the entity and the relationship between entities into a relational model. The relationship model converted from the entity:

User information form { user ID , password, gender, email, security question, security answer, remarks}.

Administrator information table { administrator ID , password}.

Post information table { post ID , content, publication time, content, user ID, news ID}.

News information table { news ID , news title, news content, update time, zone ID}.

Zone information table { zone ID , zone name, zone number}.

4.2 Physical Design

The physical design of the database includes: selecting the storage structure, determining the access method, selecting the access path, and determining the storage location of the data.

It mainly solves the problems of selecting the file storage structure and determining the file access method. The path of accessing data in the database is mainly manifested as how to build an index. If you want to directly locate the record you want to find, you should use the index method access method (index table). The sequence table can only access records one by one from the starting point to the backward. On the basis of the above entities and the relationship patterns between entities, the tables in the database and the relationships between the tables are formed.

The user information table is shown in Table 4-1.

Table 4-1 User information table

field name

illustrate

type

length

Can it be empty

primary key

id

table id

Int

20

no

yes

cusName

username

varchar

30

no

no

realName

actual name

varchar

50

yes

no

phone

Phone number

varchar

11

yes

no

email

Mail

varchar

30

yes

no

idcard

ID number

varchar

18

yes

no

sex

gender

varchar

10

no

no

province

Province

varchar

30

yes

no

city

city

varchar

30

yes

no

address

Address

varchar

255

yes

no

password

password

varchar

50

yes

no

status

state

Int

10

yes

no

The post information table is shown in Table 4-2.

Table 4-2 Post information table

field name

illustrate

type

length

Can it be empty

primary key

id

post id

Int

20

no

yes

cusName

user login name

varchar

30

yes

no

eventName

time name

varchar

255

yes

no

eventTime

Time of occurrence

varchar

30

yes

no

eventPlace

Occurrence platform

varchar

100

yes

no

eventType

event category

varchar

30

yes

no

pic

screenshot

varchar

255

yes

no

submitTime

Time of occurrence

varchar

30

yes

no

flag

Approval Status

Int

20

yes

no

The type table is shown in Table 4-3.

Table 4-3 Type table

field name

illustrate

type

length

Can it be empty

primary key

id

Type ID

Int

50

no

yes

typecode

category number

varchar2

20

no

no

typename

classification name

varchar2

50

no

no

The administrator information table is shown in Table 4-4.

Table 4-4 Administrator information table

field name

illustrate

type

length

Can it be empty

primary key

admname

Admin ID

varchar2

20

no

yes

password

administrator password

varchar2

20

no

no

The processing result table is shown in Table 4-5.

Table 4-5 Processing result table

field name

illustrate

type

length

Can it be empty

primary key

id

table id

Int

20

no

yes

infoId

information id

Int

20

no

no

result

result

varchar

255

no

no

returnPerson

Feedback person

varchar

30

no

no

returnTime

feedback time

varchar

30

no

no

The post rejection record table is shown in Table 4-6.

Table 4-6 Post rejection record table

field name

illustrate

type

length

Can it be empty

primary key

id

table id

Int

20

no

yes

infoId

information id

Int

20

no

no

checkname

Refusal person

varchar

40

no

no

check time

rejection time

varchar

30

no

no

noReson

Reason for rejection

varchar

255

no

no

5. Realize the rendering

(1) Client login

(2) User information filling page

 (3) Client personal center

 (4) Background management terminal login

(5) Log in to the main page of the background management terminal

(6) Administrator management

(7) User management

(8) Category management

(9) Handling of information reporting

 (10) Review of reported information

 (11) Export of reporting information

 6. Reference code

@WebServlet("/adminsave")
public class AdminAddServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //编码
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");

        //获取页面信息
        String id=req.getParameter("id");
        String username=req.getParameter("username");
        String realname=req.getParameter("realname");
        String sex=req.getParameter("sex");
        String phone=req.getParameter("phone");
        String idcard=req.getParameter("idcard");
        String province=req.getParameter("province");
        String city=req.getParameter("city");
        String password=req.getParameter("password");
        Admin admin=new Admin();

        admin.setUsername(username);
        admin.setRealname(realname);
        admin.setSex(sex);
        admin.setPhone(phone);
        admin.setIdcard(idcard);
        admin.setProvince(province);
        admin.setCity(city);
        admin.setPassword(password);
        AdminService adminService=new AdminServiceImpl();
        PrintWriter out = resp.getWriter();
        if(id==null||id==""){
            //增
            admin.setPassword("123456");
            int flag=adminService.insert(admin);
            if(flag==1){
                out.print("新增成功");
            }else{
                out.print("新增失败");
            }
            out.flush();
        }else {
            admin.setId(Integer.valueOf(id));
            //改
            int flag=adminService.update(admin);
            if(flag==1){
                out.print("修改成功");
            }else{
                out.print("修改失败");
            }
            out.flush();
        }

    }
}
@WebServlet("/admindelete")
public class AdminDeleteServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //编码
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        String id=req.getParameter("id");
        AdminService adminService = new AdminServiceImpl();
        Admin admin=new Admin();
        admin.setId(Integer.valueOf(id));
        Integer flag=adminService.delete(admin);
        PrintWriter out = resp.getWriter();
        out.print("删除成功");
        req.getRequestDispatcher("/adminlist").forward(req,resp);
    }
}
@WebServlet("/adminedit")
public class AdminEditServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //编码
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        String id=req.getParameter("id");
        AdminService adminService = new AdminServiceImpl();
        Admin admin=new Admin();
        admin.setId(Integer.valueOf(id));
        try {
            admin=adminService.selectOneById(admin);
            req.setAttribute("admin",admin);
            req.getRequestDispatcher("/files/admin/add.jsp").forward(req,resp);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
@WebServlet("/adminlist")
public class AdminListServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //编码
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("UTF-8");
        AdminService adminService = new AdminServiceImpl();
        Page page=new Page();
        //获取当前页面
        String currno = req.getParameter("currPageNo");

        //获取条件
        String username = req.getParameter("username");

        Admin admin=new Admin();
        admin.setUsername(username);
        if(currno==null){
            currno="1";
        }else{
            page.setCurrPageNo(Integer.valueOf(currno));
        }

        List<Admin> adminlist = new ArrayList<>();
        try {
            List countList = adminService.selectAllAdmin(null);
            page.setTotalCount(countList.size());
            adminlist=adminService.selectAdminsByPage(admin,Integer.valueOf(currno),page.getPageSize());
            page.setList(adminlist);
            req.setAttribute("page",page);
            req.setAttribute("username",username);
            req.getRequestDispatcher("/files/admin/list.jsp").forward(req,resp);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
@WebServlet("/infoedit")
public class InfoEditServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //编码
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        String id=req.getParameter("id");
        AdminService adminService = new AdminServiceImpl();
        Admin admin=new Admin();
        admin.setId(Integer.valueOf(id));
        try {
            admin=adminService.selectOneById(admin);
            req.setAttribute("admin",admin);
            req.getRequestDispatcher("/files/admin/info.jsp").forward(req,resp);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
@WebServlet("/infolist")
public class InfoListServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //编码
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("UTF-8");
        InfoService infoService=new InfoServiceImpl();
        Page page=new Page();
        //获取当前页面
        String currno = req.getParameter("currPageNo");

        //获取条件
        String eventName = req.getParameter("eventName");
        //获取状态
        String flag = req.getParameter("flag");

        Info info=new Info();
        info.setFlag(Integer.valueOf(flag));
        info.setEventName(eventName);
        if(currno==null){
            currno="1";
        }else{
            page.setCurrPageNo(Integer.valueOf(currno));
        }

        List<Info> infolist = new ArrayList<>();
        try {
            List countList = infoService.selectAllInfos(info);
            page.setTotalCount(countList.size());
            infolist=infoService.selectInfosByPage(info,Integer.valueOf(currno),page.getPageSize());
            page.setList(infolist);
            req.setAttribute("page",page);
            req.setAttribute("eventName",eventName);
            req.setAttribute("flag",flag);
            req.getRequestDispatcher("/files/info/list.jsp").forward(req,resp);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
@WebServlet("/resultedit")
public class RecordEditServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //编码
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        String id=req.getParameter("id");
        ResultService resultService = new ResultServiceImpl();
        Result result=new Result();
        result.setId(Integer.valueOf(id));
        req.setAttribute("id",id);
        req.getRequestDispatcher("/files/result/add.jsp").forward(req,resp);
    }
}
@WebServlet("/recordsave")
public class RecordSaveServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //编码
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");

        //获取页面信息
        String id=req.getParameter("infoId");
        String noReson=req.getParameter("noReson");

        Record record=new Record();

        record.setInfoId(Integer.valueOf(id));
        record.setNoReson(noReson);
        Date nowdate=new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        record.setChecktime(sdf.format(nowdate));
        HttpSession session=req.getSession();
        Admin admin=(Admin)session.getAttribute("user");
        record.setCheckname(admin.getUsername());

        RecordService recordService=new RecordServiceImpl();
        PrintWriter out = resp.getWriter();
        //增
        int flag=recordService.insert(record);
        //修改信息表状态
        Info info=new Info();
        info.setId(Integer.valueOf(id));
        InfoService infoService=new InfoServiceImpl();
        try {
            info=infoService.selectInfoById(info);
            info.setFlag(-1);
            infoService.update(info);

            //获取当前用户虚构提交的次数
            Integer zs=infoService.countCusWg(info.getCusName());
            UserService userService=new UserServiceImpl();
            User user=new User();

            if(zs>=2){
                user=userService.selectUserByName(info.getCusName());
                user.setStatus(2);
                //封号
                userService.update(user);
            }
            if(flag==1){
                out.print("驳回成功");
            }else{
                out.print("驳回失败");
            }
            out.flush();
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
@WebServlet("/inforecord")
public class InfoRecordServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //编码
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        String id=req.getParameter("infoId");
        RecordService recordService=new RecordServiceImpl();
        Record record=new Record();
        record.setInfoId(Integer.valueOf(id));
        List<Record> recordList=new ArrayList<>();
        try {
            recordList=recordService.selectRecords(record);
            if(recordList.size()!=0){
                record = recordList.get(0);
            }
            req.setAttribute("record",record);
            req.getRequestDispatcher("/files/info/inforecord.jsp").forward(req,resp);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
@WebServlet("/resultsave")
public class ResultAddServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //编码
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");

        //获取页面信息
        String id=req.getParameter("infoId");
        String result1=req.getParameter("result");

        Result result=new Result();

        result.setInfoId(Integer.valueOf(id));
        result.setResult(result1);
        Date nowdate=new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        result.setReturnTime(sdf.format(nowdate));
        HttpSession session=req.getSession();
        Admin admin=(Admin)session.getAttribute("user");
        result.setReturnPerson(admin.getUsername());

        ResultService resultService=new ResultServiceImpl();
        PrintWriter out = resp.getWriter();
        //增
        int flag=resultService.insert(result);
        //修改信息表状态
        Info info=new Info();
        info.setId(Integer.valueOf(id));
        InfoService infoService=new InfoServiceImpl();
        try {
            info=infoService.selectInfoById(info);
            info.setFlag(2);
            infoService.update(info);
            if(flag==1){
                out.print("新增成功");
            }else{
                out.print("新增失败");
            }
            out.flush();
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
@WebServlet("/resultinfo")
public class ResultInfoServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //编码
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        String id=req.getParameter("infoId");

        ResultService resultService=new ResultServiceImpl();
        Result result=new Result();
        result.setInfoId(Integer.valueOf(id));
        List<Result> results=new ArrayList<>();
        try {
            results=resultService.selectResults(result);
            if(results.size()!=0){
                result = results.get(0);
            }
            req.setAttribute("result",result);
            req.getRequestDispatcher("/files/result/inforesult.jsp").forward(req,resp);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
@WebServlet("/resultinfolist")
public class ResultListServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //编码
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("UTF-8");
        InfoService infoService=new InfoServiceImpl();
        Page page=new Page();
        //获取当前页面
        String currno = req.getParameter("currPageNo");

        //获取条件
        String eventName = req.getParameter("eventName");
        //获取状态
        String flag = req.getParameter("flag");

        Info info=new Info();
        info.setFlag(Integer.valueOf(flag));
        info.setEventName(eventName);
        if(currno==null){
            currno="1";
        }else{
            page.setCurrPageNo(Integer.valueOf(currno));
        }

        List<Info> infolist = new ArrayList<>();
        try {
            List countList = infoService.selectAllInfos(info);
            page.setTotalCount(countList.size());
            infolist=infoService.selectInfosByPage(info,Integer.valueOf(currno),page.getPageSize());
            page.setList(infolist);
            req.setAttribute("page",page);
            req.setAttribute("eventName",eventName);
            req.setAttribute("flag",flag);
            req.getRequestDispatcher("/files/result/list.jsp").forward(req,resp);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

7. Summary

In the process of developing the JavaWeb-based network bad information reporting platform, we made full use of the characteristics and advantages of JavaWeb technology and successfully built a fully functional, safe and reliable platform. The following are some of our conclusions and gains during the development process:

(1) Reasonable technology selection: JavaWeb technology provides a wealth of tools and frameworks, enabling us to quickly develop a fully functional platform. We chose the Java Web development technology suitable for this project - JDBC, Servlet, these technologies can improve development efficiency, and have good scalability and maintainability.

(2) Considering the user experience: In the design of the platform, we pay attention to the user experience and strive to provide a simple and intuitive operation interface so that users can quickly get started and complete the reporting operation. At the same time, considering user privacy and security, a report function is provided to protect users' personal information and security.

(3) Sound security measures: Since it involves reporting materials uploaded by users, we pay special attention to the security of the platform during the development process. For the files uploaded by users, we have conducted strict audits to ensure security.

In short, through JavaWeb-based development, we have successfully built a platform for reporting bad information on the Internet, realizing safe, fast, and anonymous reporting functions, and adding social design to promote user participation and information exchange. During the development process, we made full use of the advantages of JavaWeb technology, taking into account the functionality, security and user experience of the platform, providing users with an efficient and convenient reporting channel, helping to purify the network space and maintain social order.

Guess you like

Origin blog.csdn.net/lf21qp/article/details/131549300