Java Graduation Project - Design and Implementation of Online Shopping System Based on JSP+JavaBean+sqlserver (Graduation Thesis + Program Source Code) - Online Shopping System

Design and implementation of online shopping system based on JSP+JavaBean+sqlserver (graduate thesis + program source code)

Hello everyone, today I will introduce to you the design and implementation of an online shopping system based on JSP+JavaBean+sqlserver. At the end of the article, the thesis and source code download address of this graduation project are attached. Friends who need to download the proposal report PPT template and thesis defense PPT template, etc., can go to my blog homepage to view the self-service download method in the bottom column on the left.

Article directory:

1. Project introduction

  1. E-commerce (Electronic Commerce) is a new concept emerging on the Internet. It uses computer technology, network technology and remote communication technology to realize electronics, digitization and networking in the entire business (buying and selling) process. With its widespread use, it has brought convenience to people and gradually changed people's lifestyles.
  2. Most domestic online shopping websites are implemented using ASP and PHP technologies, but there are few excellent websites based on JSP. This system, the online book supermarket, is designed and implemented using the JSP+JavaBean+SQL Server database three-tier model. This paper elaborates on the system's demand analysis, overall system architecture, detailed design and module implementation process. It mainly implements the following module functions: member registration, login/logout; user management; browsing book details; book search; book management ; Shopping cart; orders; order management, etc.


2. Resource details

Project difficulty: medium difficulty
Applicable scenario: graduation project on related topics
Word count of supporting paper: 12564 words and 33 pages< a i=3>Contains: full set of source code + completed thesisRecommended download method for ppt templates such as proposal report, thesis defense, project report, etc.:


Insert image description here


3. Keywords

JSP; SQL Server; JavaBean; online shopping

4. Introduction to Bishe

Tip: The following is a brief introduction to the graduation thesis. The complete source code of the project and the download address of the complete graduation thesis can be found at the end of the article.

1 Introduction
1.1 Background of the topic
JSP is a website development technology launched by Sun Company. Sun Company relies on its extraordinary achievements in Java , and introduced people to the JSP era, JSP is Java Server Page, which can complete powerful Web applications with the support of Servlet and JavaBean. JSP website construction will become the trend of future website construction. Most domestic electronic shopping websites are implemented using ASP and PHP technologies, but there are few excellent websites based on JSP. Therefore, in my graduation project, I used JSP as a development tool to build a small dynamic business website that can implement simple e-commerce - an online book supermarket sales system. The system can realize user registration and login functions; it can also realize product inquiry, ordering and other functions. This system basically has the functions that an online merchandise sales system should have. This design project basically embodies the technology required to build a dynamic business website. It can be said that the current large-scale business websites are the content of our small website. Expand and repeat.
1.2 Research status at home and abroad
Omitted

1.3 Research methods for this topic
This graduation project should first analyze the relevant functions of Taobao, eBay and other shopping websites, and write down the requirements based on the relevant requirements of this graduation project Analysis; secondly, comprehensively use the relevant knowledge learned before (including computer network technology, related protocols, information security, JSP and other related knowledge, etc.), select familiar development tools to develop this graduation project; use demand analysis in the design Based on this, write down the system development plan, implementation process and implementation methods for related issues.
2 About JSP
2.1 Introduction to JSP
JSP (Java Server Pages) is a function built on the functions provided by the Servlet specification. The dynamic web page technology on the Internet is similar to ASP. They embed script code in ordinary web page files to generate dynamic content, but JSP files embed JAVA code and JSP tags.
The JSP file will be compiled into a Servlet when the user requests it for the first time, and then this Servlet will process the user's request, so JSP can also be regarded as a runtime Servlet.
Omitted

2.2 The operating principle of JSP
When JSP receives a request from the client browser for the first time, the JSP file will be converted into a Servlet by the JSP engine. That is, the ".jsp" file is compiled into a Java Class file. When the Servlet engine receives the request, if it is set to use the latest JSP, it will go to the JSP file and check whether the file has been changed since the last compilation. If it is changed, it will be recompiled to generate a new Servlet, and finally the request will be transferred to the compiled Servlet engine for execution.
If any syntax errors are found in the JSP file during compilation, the conversion process will be interrupted and an error message will be sent to the client; if the compilation is successful, the Servlet code generated by the conversion will be compiled, and then the Servlet is loaded into memory by JSP engine. At this time, the JSP engine also requested the execution of the jspInit() method and initialized the Servlet. The JspInit() method is only requested once in the Servlet's life cycle and will then be called to handle the client's request and reply operations. For all subsequent requests to the JSP file, the server will check whether the JSP file has been modified since it was last accessed. If there is no modification, the request is returned to the jspService() method of the Servlet still in the memory and the reply operation is performed. Since the Servlet always resides in memory, the response is very fast. When the Jsp page is accessed for the first time, it runs slowly because it needs to be converted and compiled. However, when the page is accessed for the second time, the file has been compiled into a bytecode file, so the speed is very fast.
2.3 Composition of JSP pages
JSP pages look like standard HTML and XML pages, and come with codes and components that the JSP engine can process, parse and execute. Typically, JSP code and components are used to create the text that is displayed on the final page. Generally speaking, JSP pages include compilation instructions, declarations, expressions and other contents.
Omitted

2.4 JSP operating environment
To run Jsp (note, not to browse Jsp pages), you need a server that supports Jsp. There are two situations here: one is a server that supports Jsp itself, such as Jrun, Weblogic, JSWDK, etc.; and the other is a Jsp engine plug-in installed on a server that does not support Jsp, such as IIS, Apache and other servers. Install plug-ins such as WebSphere, tomcat, and Resin on the computer. The mainstream servers are Weblogic and tomcat.
Tomcat server is a free server software developed by the Apache Group Jakarta team. It is suitable for embedding in Apache. Moreover, its source code is available for free. You can Feel free to expand on it. The visited address is http://jakarta. apache.org/tomacat/index.html. The compatibility of Tomcat server is very good. For example, WebLogic server uses it as the web server engine, Jbuilder uses it as a standard test server, and Sun company also uses it. It serves as a sample server for JSP technology applications. The disadvantage is that its configuration is more troublesome, and some security issues have not been resolved. However, the Tomcat server is supported by many large software companies, and the server's performance is stable, and its development prospects are very good.

2.5 Introduction to JavaBean Technology
Omitted

3 Requirements Analysis
3.1 System Description
This system is a small and medium-sized e-commerce system----online book supermarket, which can provide various It provides users with a convenient online book buying environment, which is in line with the current domestic popular e-commerce model. Users can register, browse books, search and query books, place orders, process orders and other functions in the system; administrators can maintain and update the system through user management, order management, book management, announcement management, voting management and other management functions. .
3.2 Introduction to system functions
The online book supermarket system is a typical JSP database development application, which consists of two parts: front-end product display and sales, and back-end management.
 Product display and sales at the front desk
This part mainly includes new book shelves, key recommendations, sales rankings, shopping carts, member management, checkout and order inquiries, and merchandise Inquiry etc.
 Backend management
This part mainly manages some basic data in the mall effectively, including book management, user management, order management, announcement management, etc.

4 System Design
4.1 Function Module
The front-end functional structure of the online book supermarket is shown in Figure 1
Insert image description here

Figure 1 Front-end functional structure diagram
The back-end functional structure of the online book supermarket is shown in Figure 2
Insert image description here

Figure 2 Backend function structure diagram
4.2 System design idea
This system adopts a three-layer architecture design, and its working principle is shown in Figure 3 .

After adopting the three-tier architecture, the user interface layer sends requests to the business layer through a unified interface. The business layer processes the requests according to its own logical rules and then performs database operations, and then encapsulates the data returned by the database into the form of classes. Return to the user interface layer. In this way, the user interface layer does not even need to know the structure of the database. It only needs to maintain the interface with the business layer.
4.3 Overall system process
Insert image description here

Figure 4 User Flow Chart
Since the background management flow chart is basically the same as the user flow chart, only the user flow chart in Figure 4 is shown as an example
4.4 Website setup
4.4.1 Development environment
Omitted

4.4.2 Create a site
Create a folder under the Tomcat 5.5\webapps folder with the name of the online book supermarket system BookSupermarket, and then create WEB-INF under BookSupermarket (note all is uppercase) folder, and finally create the classes folder under WEB-INF, the lib folder and web.xml to save the class files, and the required storage information and site information are guaranteed.
4.5 Database design
This system database uses SQL Server 2005 database. The system database name is db_bookmanage. It contains a total of 8 tables. Corresponding data is established according to the needs of the project. The design results of the table are as follows:
Table 1 Book information table tb_bookinfo
Field name data type length allows empty description
ISBN varchar 15 Book ISBN number, primary key
BookName varchar 200 Book name
Type varchar 50 Book category name
publisher varchar 100 Publishing Company name
Writer varchar 100 Author
Introduce text 16 yes Book introduction
Price money 8 Price
pDate varchar 50 yes publication date
cover varchar 100 yes book cover file name
INTime datetime 8 book information entry time
newbook int 4 indicates whether the book is a new book
commend int 4 yes indicates whether the book is recommended, 1 indicates recommendation, and the default value is 0 indicates not recommended

Table 2 User Information Table tb_Member
Field name data type length allows empty description
ID int 4 Primary key automatic number, user ID number Amount money 8 yes Consumption amount grade int 4 yes User level CardType varchar 20 yes Card type CardNO varchar 24 yes certificate number Postcode varchar 6 postal code address varchar 100 contact address city varchar 20 city PassWord varchar 20 user password TrueName varchar 20 no user’s real name
username varchar 4 no username Email varchar 100 Email address freeze int 4 yes Whether it is frozen, 1 means frozen, 0 means frozen Not frozen











Table 3 Order information main table tb_Order
Field name data type length allows empty description
Order ID bigint 8 automatic number, order number a> enforce int 4 yes flag is executed, a value of 1 means it has been executed, a value of 0 means it has not been executed< /span> bz varchar 200 yes Remarks information OrderDate smalldatetin 4 Order date rebate float 8 discount carry varchar 20 shipping method pay varchar 20 payment method email varchar 100 E-mail address tel varchar 20 Contact number postcode varchar 10 Postal code address varchar 100 Contact address Truename varchar 15 user’s real name username varchar 15 user name
bnumber smallint 2 number of varieties











Table 4 order information details table tb_order_detail
Field name data type length allows empty description
ID bigint 8 automatic number of order information details numer int 4 Purchase Quantity price money 8 unit price ISBN varchar 20 book ISBN number
orderID bigint 8 order number


Table 5 discount information table tb_rebate
Field name data type length allows empty description
grade varchar 20 automatic number, grade
Amount money 8 consumption amount
rebate float 8 discount rate

Table 6 Administrator information table tb_manager
Field name data type length allows empty description
ID int 4 automatic number
manager varchar 30 administrator name
PWD varchar 30 password

Table 7 Announcement Information Table tb_BBS
Field name data type length allows empty description
ID int 4 automatic number
content varchar 4000 Announcement content
INTime datetime 8 yes Announcement content, the default value is getdate()

Table 8 Voting information table tb_Poll
Field name data type length allows empty description
ID int 4 automatic number
optionName varchar 50 voting item
poll int 4 number of votes, default is 0

5 System Implementation
5.1 Writing JavaBeans
Write the required JavaBeans according to the needs of the system. The following will give the writing process of JavaBeans required by the online book supermarket.
5.1.1 Implementation of JavaBean for database operations
In the system development process, database operations are often required, which requires connecting to the database and operating the database (including data Insert, update, delete and query, etc.), the JavaBean for database operations is a public class, which usually includes the method getConnection to connect to the database, the method executeQuery to execute the query statement, the method executeUpdate to perform the update operation, and the method close to close the database connection. Therefore, program development can write the code for connecting to the database and operating the database as a JavaBean "connDB.java". After writing, place the source code in the Tomcat 5.5\webapps\BookSupermarket\WEB-INF\src\beans folder.

5.1.2 Implementation of JavaBean for string processing
JavaBean for string processing is a class that solves string processing problems that often occur in programs. It includes two methods, chStr, which correctly displays and stores strings with Chinese problems in the database and pages, and convertStr, which correctly displays carriage returns, line feeds, spaces and HTML tags in strings. The following is the detailed process of writing the JavaBean "chStr" for string processing in the online book supermarket.
(1) Write a method chStr to solve the problem of outputting Chinese garbled characters.
(2) Then write the method convertStr to display carriage returns, line feeds and spaces in the text and ensure the normal output of HTML tags.

5.1.3 Implementation of JavaBean to save shopping information
In the shopping cart program, a bookelement object needs to be used to save the selected book information, and the JavaBean "bookelenent.java" of the object is generated. code.
5.2 Implementation of the main functional modules of the website front desk
5.2.1 Design of the website front desk homepage
According to the early analysis and customer requirements, The front desk of the online book supermarket mainly includes modules such as key recommendation booths, new book shelves, book classification, book inquiry, user management, shopping cart, order generation, order inquiry and sales ranking. The running results on the homepage of the online supermarket front desk are shown in Figure 5 below
Insert image description here

Figure 5 Home Page

5.2.2 Implementation process of the key recommendation booth
(1) In the center of the front desk of the website, the book information recommended by the supermarket is listed in columns, mainly including book covers, names , publisher, author and pricing information. At the same time, an "Add to Cart" button and a "View" button are listed, which are used to add books to the shopping cart and view detailed information about the book respectively. The key recommended book information is stored in the book information table tb_bookinfo at the same time as the basic book information, and is identified by the field command. When the value of the command field is 1, it means that the book is a key recommended book. The code to query the recommended books is as follows:
<%
ResultSet rs_book=connDB.executeQuery(“select * from tb_bookinfo where commend=1”); a>
%>
It should be noted here that the "Add Shopping Cart" button can only be displayed after the user is logged in, that is, only logged in users can purchase books. .
(2) Query the detailed information of the book based on the ISBN number of the book. The running results of the book details page are shown in Figure 6:
Insert image description here

Figure 6 Book Introduction
In the book_detail.jsp page, first query the book information that matches the ISBN value. The key code is as follows:

<%
ResultSet rs=connDB.executeQuery("select * from tb_bookinfo where ISBN='"+request.getParameter("ISBN")+"'");
%>

Display the query results on the page. At this time, the "Book Introduction" needs to be processed so that carriage returns, line feeds and space characters can be displayed correctly. The key code is as follows:

<%
			  if(rs.next()){
    
    
			  //注意:此处只能按照字段的顺序读取
			  	String ISBN=rs.getString("ISBN");
			  	String bookname=rs.getString("BookName");
				String publisher=rs.getString("publisher");
				String writer=rs.getString("writer");
				String Introduce=chStr.convertStr(rs.getString("Introduce"));
				int price=rs.getInt("Price");
				String pDate=rs.getString("pDate");
				String cover=rs.getString("cover");
			  %>
			  …… //此处省略了显示图书信息的HTML代码
			 <%}%>

5.2.3 Implementation process of new books on shelves
In the front home page, click the "New books on shelves" hyperlink to enter the new book shelves page newbook.jsp. The running results are shown in Figure 7< /span>
Insert image description here

Figure 7 New book on the shelf
The new book on the shelf message is stored in the book information table tb_bookinfo, marked by the field newbook. When the value of the newbook field is 1, it means that the book is a new book on the shelf. Key code for new book listing page:
<%
ResultSet rs_newbook=connDB.executeQuery(“select * from tb_bookinfo where newbook=1 order by INTime desc”);
%>

5.2.4 Book classification implementation process
In order to facilitate users to query the required book information, a book classification display module is set up in the website. Click the "Book Category" hyperlink in the navigation bar to enter the book category display page. All book categories in the database are listed in the "Book Category List" on the left of the page. Users can click to display the book on the right. Information list, click on the book title to view the detailed information of the corresponding book. If the user is logged in, the user can also directly add the book information to the shopping cart. The running result of the book classification display page is shown in Figure 8
Insert image description here

Figure 8 Book Classification
All the book categories in the database are listed in the "Book Classification List" on the left side of the book classification page BookSort.jsp. The main way to query book categories is through the Select statement. Group By clause implementation, specific process:
<%
ResultSet rs_Type=connDB.executeQuery(“select Type from tb_bookinfo group by Type”);%> ;
When displaying book classification information, it should be noted that you can no longer use the while statement, but should use the do...while statement, otherwise there will be one less record. This is because when specifying the default category of a book, The rs_Type.next() statement has been used to move the record pointer to the next record, and the key code for displaying book classification information is:
<%rs_Type.first();
do{//Do...while must be used here, otherwise there will be one less record
String Type=rs_Type.getString("Type");
%>
…… //Omit the order information code here
<%}while (rs_Type.next());%>
The book information of the specified category will be displayed in the book list on the right side of the book classification page BookSort.jsp. When the user does not select a category, the default category can be specified by obtaining the value of the first record in the category result set rs_Type. Otherwise, the getParameter method of the request object is used to obtain the selected category and query, part of the code:

String PType="";
if (request.getParameter("Type")!=null){
    
    
	PType=chStr.chStr(request.getParameter("Type"));
}else{
    
    
	if(rs_Type.next()){
    
    
		PType=rs_Type.getString("Type");
	}else{
    
    response.sendRedirect("index.jsp");
	}}
ResultSet rs_book=connDB.executeQuery("select * from tb_bookinfo where Type='"+PType+"'");
%>

5.2.5 User management implementation process
User management mainly includes user registration, user login, and user profile modification. Since user profile modification is relatively simple, no further explanation will be given.
1. User Registration
For unified management, the system stipulates that only members can purchase books, so new users who want to purchase books must first register as a user. The entrance for user registration is on the left side of the homepage of the website. The user clicks "Register" to enter the user registration page, as shown in Figure 9
Insert image description here

Figure 9 User Registration
The website requires that the user name must be unique. Users can first check whether their user name has been registered. Since it is a network program, when saving user information after registration, the registered user needs to be detected again. If it does not exist, the user information is saved. Otherwise, it will prompt that the user has already been registered, please register again. Save the user registration information page register_deal.jsp.
2. User login
The user login window is shown in Figure 10
Insert image description here

Figure 10 User login
If the user name entered by the user exists and the value of the frozen field is not 1, then determine whether the password entered by the user is correct. If the password is also correct, then Log in successfully, otherwise it will prompt login failure.

5.2.6 Shopping cart implementation process
The shopping cart mainly includes four parts: adding selected books, viewing the shopping cart, modifying the purchase quantity of a single book, and clearing the shopping cart.
1. Add to shopping cart cart_Add.jsp
Mainly uses the Vector type variable cart to store shopping data, which is saved in Session, and then saves the book information into the cart. The main code:

String ISBN=chStr.chStr(request.getParameter("ISBN"));
String sql="select * from tb_bookinfo where ISBN='"+ISBN+"'";
ResultSet rs=connDB.executeQuery(sql);
float price=0;
if(rs.next()){
    
    price=rs.getInt("price");}
bookelement mybookelement=new bookelement();
mybookelement.ISBN=ISBN;
mybookelement.price=price;
mybookelement.number=1;
boolean Flag=true;
Vector cart=(Vector)session.getAttribute("cart");
if(cart==null){
    
    
	cart=new Vector();}else{
    
    
	for(int i=0;i<cart.size();i++){
    
    
		bookelement bookitem=(bookelement)cart.elementAt(i);
//当cart中已经存在所添加的图书信息时,只将数量加1
		if(bookitem.ISBN.equals(mybookelement.ISBN)){
    
      //此处必须用equals方法,不能用==
			bookitem.number++;
			cart.setElementAt(bookitem,i);
			Flag=false;
		}}}if(Flag)cart.addElement(mybookelement);
session.setAttribute("cart",cart);//将cart保存到session中
rs.close();
response.sendRedirect("cart_see.jsp");
%>

2. View the shopping cart
To view the top of the shopping cart page cart_see.jsp, you first need to determine whether the shopping cart is empty. If it is empty, the page will jump directly to the empty shopping cart page cart_null.jsp, otherwise it will be displayed. Shopping cart information. Displaying the shopping cart information mainly uses the for statement to output the data saved in the Session to IE. At the same time, it automatically calculates the amount of each book and the total amount of all books in the shopping cart based on the book's pricing and purchase quantity. The code is as follows:
Omitted
Insert image description here

Figure 11 Shopping cart
As shown in Figure 11, since the name of the book is not saved in the shopping cart, when obtaining the book information, you need to re-enter the data according to the ISBN number of the book. Check the book name in the table, the code is as follows:

 ResultSet rs_newbook=connDB.executeQuery("select * from tb_bookinfo where ISBN=‘“+ ISBN+”’”);
If(re_book.next()){
    
    
Bookname=re_book.getString(“Bookname”);
3.	从购物车中移去指定图书
实现从购物车中移去指定图书可以通过Vector类的removeElementAt(int index)方法实现,非常方便。页面cart_move.jsp代码为:
Vector cart=(Vector)session.getAttribute("cart");
try{
    
    
	String ID=request.getParameter("ID");
	int id=Integer.parseInt(ID);
	cart.removeElementAt(id);//移去指定图书信息
	session.setAttribute("cart",cart);
	response.sendRedirect("cart_see.jsp");
	}catch(Exception e){
    
    
}
%>

4. Clearing the shopping cart
The implementation method is very simple. You only need to clear the shopping information saved in the Session. The code for clearing the shopping cart page cart_clear.jsp is:
session.removeAttribute(“cart”);
response.sendRedirect(“cart_null.jsp”);

5.2.7 Generating Order Implementation Process
When generating an order, not only the book information and order information purchased in the user's order must be saved, but also a data must be returned for the user to query at any time. unique order number.
The user views the "Go to checkout" hyperlink in the shopping cart page and enters the checkout page to fill in the order information. On this page, the system will automatically fill in the order information based on the user's logged in user name. The user's basic information can be modified except for the user name, which cannot be changed. The running result of the cashier page is shown in Figure 12
Insert image description here

Figure 12 Checkout
In the checkout page cart_checkout.jsp, the application first determines whether the user has made a purchase, and then determines whether the user is logged in. If the user has not made a purchase or is not logged in You will be prompted and returned to the homepage of the website. The key code is:

<%if(session.getAttribute("cart")==""){
    
    
	out.println("<script language='javascript'>alert('您还没有购物!');window.location.href='index.jsp';</script>");
}
String Username="";
Username=(String)session.getAttribute("UserName");
if (Username!=""){
    
    
try{
    
    
ResultSet rs_user=connDB.executeQuery("select * from tb_Member where username='"+Username+"'");
if(!rs_user.next()){
    
    
	session.invalidate();
	out.println("<script language='javascript'>alert('请先登录后,再进行购物!');window.location.href='index.jsp';</script>");
	return;
}else{
    
    
	String Truename=rs_user.getString("Truename");
	String address=rs_user.getString("address");
	String postcode=rs_user.getString("postcode");
	String tel=rs_user.getString("tel");
	String email=rs_user.getString("email");
%>

5.2.8 Order Query Implementation Process
The order query implementation page is designed for users to query the execution status of order information. After the user successfully logs in, click "Order Query" on the website ” to enter the order query page, which lists a list of all order summary information of the current user. Querying order summary information mainly obtains order information from the main order table tb_order based on the currently logged in user name. The key code is as follows:
ResultSet rs=connDB.executeQuery(“select * from tb_Order where username=& #39;”+(String)session.getAttribute(“UserName”)+“'”);
and view the order details based on the order number.

5.2.9 Sales Ranking Implementation Process
The running results of this page are shown in Figure 13
Insert image description here

Figure 13 Sales Ranking
The sales ranking data mainly consists of grouping the quantity ISBN field in the sales detail table, counting the sales quantity, and then applying a subquery to obtain the top 10 books with the highest sales quantity. , and finally use the connection query to obtain the corresponding book information. The key code is as follows:
ResultSet rs_sort=connDB.executeQuery(“select * from (select top 10 * from ( select sum(number) as amount ,ISBN from tb_Order_detail group by ISBN )as tab order by amount desc) o inner join tb_bookinfo b on o.ISBN=b.ISBN order by o.amount desc”);

5.3 Design of main functional modules of the website backend
There are seven main modules in the backend design, namely: backend login, book management, user management, and order management. Announcement management, voting management, exit.
5.3.1 Background login implementation process
The running result of the background login page is shown in Figure 14
Insert image description here

Figure 14 Backend login
In order to ensure the security of the website and prevent some criminals from deliberately sabotaging it, it is necessary to design the file safe.jsp for the backend of the website to verify user identity. The complete code is as follows:
<%if (session.getAttribute(“UserName”)==null){ out.println(""); }%> Then, each page after the homepage of the website Add the following code: <jsp:include page="safe.jsp"/> In this way, when the user does not log in normally, the "You Not logged in yet" prompt dialog box. After confirmation, you will exit the background page and return to the homepage of the website.




5.3.2 Book management page implementation process
The book management module mainly implements the management of book information, including displaying book information in pages, adding book information, modifying book information, and deleting book information. and other functions.
1. Display book information in pages
Display the book information page in pages. The main purpose is to display the book information in the data table in a list, and add hyperlinks for modification and deletion to facilitate future modification of the book information. Modification and deletion. The running result of displaying the book information page in pagination is shown in Figure 15
Insert image description here

Figure 15 Book Management
In the paging display book information page, it mainly displays the book's ISBN number, book name, publisher, whether it is a new book, whether it is recommended, etc., as for the book's For other information, you can click the book name hyperlink to enter the book details page to query. The code to implement book query is relatively simple. You only need to use the executeQuery method of JavaBean and a SQL statement to implement it. The code is as follows:
<%
ResultSet rs=connDB.executeQuery(“select * from tb_bookinfo order by INTime Desc”);
%>
The implementation method of paging the data in the web page is as follows:
(1) Determine the record span, that is, the number of records displayed on each page. This can be done by yourself according to the actual situation of the page. Regulations, for example, this system is set to 10
(2) Confirm the total number of records, which can be obtained through the getRow() method of the result set. At this time, readers need to pay attention and use the getRow() method. You must first use the last() method of the result set.
(3) Calculate the total number of pages according to the formula "total number of pages = total number of records/span". If there is a remainder in the total number of pages, round it off and make it equal to 1 The add book information page is mainly used to add new book information to the database. The running result of adding book information page is shown in Figure 16 2. Add book information (6) Paging display through for loop Book information (5) Calculate the current number of records, the current number of records = (number of pages obtained - 1) * span + 1
(4) Get the current page number parameter (Page) passed and convert it into integer data. If the page number is less than 1, make it equal to 1. If it is greater than the maximum page number, let It is equal to the maximum number of pages.




Insert image description here

Figure 16 Book addition
In order to ensure the uniqueness of the book information in the data table, it is judged whether the book information exists based on the book ISBN number entered by the user. If it exists, a prompt message is given and Return, otherwise save the book information to the data table.
3. Delete book information
Delete the specified book information according to the parameter ISBN.

5.3.3 User management implementation process
The system administrator checks the basic information of users and freezes or unfreezes users who often break their trust. The running result of the user information management page is shown in Figure 17
Insert image description here

Figure 17 User Management
Before introducing how to freeze users and unfreeze users that have been frozen, let us first conduct a brief analysis of the user data table. In the user information table In addition to the basic user information field, tb_member also includes a field freeze that marks whether the user information is frozen. This field is of int type and the default value is 0. When designing the program, it is specified that the values ​​of this field are only 0 and 1. , 0 means not frozen, 1 means frozen. It can be seen that to freeze a user, you only need to set the freeze field value of the user to 1, and to unfreeze the user, you only need to set the freeze field to 0.
The key code to implement the frozen user page member_freeze.jsp is as follows:
if(request.getParameter(“ID”)!= “”){ int ID=Integer.parseInt(request.getParameter(“ID”)); String sql="update tb_member set freeze=1 where ID="+ ID; int ret=0; ret=connDB.executeUpdate(sql); if (ret!=0) { out.println(""); } } Description: Implement the The method of unfreezing a frozen user is similar to that of freezing a user. You only need to change the value of the freeze field to 0.








5.3.4 Order management implementation process
Order management mainly involves executing orders and viewing order details, but order information cannot be modified. The running result of the order management page is shown in Figure 18
Insert image description here

Figure 18 Order Management
The order information management home page mainly implements the interface to display order summary information in pages, execute orders and view order details. The implementation process of displaying order summary information in pages is similar to the implementation of displaying book information in pages. The difference is that in the execution column of the order list, different information needs to be displayed according to the status of the order. If the order has been executed, "Executed" is displayed. Text, otherwise provides an icon to execute the order. The key code to implement this function is as follows:
<%if(enforce==0){%><%}else{%>Already Execute the implementation of <%}%>
to display the order details page order_detail.jsp, mainly query the basic information of the order in tb_order in the order table through the order number passed on the order management homepage, and then Just query the order details and display them by trying V_order_detail.

5.3.5 Announcement Management Implementation Process
Announcement management mainly involves viewing announcement information, adding announcement information and deleting announcement information. Since announcement information involves the time when the announcement is released, the homepage must be able to Modify announcement information. The running result of the announcement management page is shown in Figure 19
Insert image description here

Figure 19 Announcement Management
When displaying announcement information, you need to call the convertStr method in JavaBean "chStr" to display carriage returns, line feeds and spaces in the announcement information.

5.3.6 Exit system implementation process
The website backend plays a vital role in the normal operation of the entire website. When the administrator completes the maintenance work of the website, he must log out of the system, otherwise if an unauthorized person takes the opportunity to enter, the consequences will be very serious. The method to log out of the website background is very simple. Just click the "Exit" hyperlink and connect to the logout .jsp page is enough. The Logout.jsp page mainly clears the Session variables that hold management information and redirects the page to the homepage of the website. The key code is as follows:
Session.invalidate();
Response.sendRedirect(“index.jsp”);
6 System test
omitted

Summary
The implementation of this system basically successfully uses the idea of ​​using JSP+JavaBean to implement business logic processing in the design idea, and achieves the purpose of customizing a small e-commerce platform. . But in order to use it as an application that can truly be used for commercial purposes, there are many functions that need further expansion and improvement. From the development, I realized that although JavaBeans were used in this design, there are still many places where Java program fragments (Java code) need to be added to the JSP page, which is very difficult for the display control of the page. Although using it may have its downside in terms of the separation of page display and business logic, using it as a small project development is an effective method. Because its principle is simple and the ideas and techniques used are easy to master. Through this design, the online bookstore I designed has basically completed the required basic functions and implemented a simple data-centered model of different parts, which can solve corresponding problems in actual operation of each part of the solution.
In the process of designing and producing an overall project of an online bookstore, I also developed my comprehensive ability and overall thinking. Simplifying complex problems, as a microcosm of e-commerce applications, the module project I was involved in completed the basic functions of its backend, making my understanding of e-commerce more in-depth and clear.
Of course, there are still some problems that need to be solved, but due to my limited level, as an online bookstore system, the project has some imperfections and needs to be improved, especially It is the security of website information that needs to be further strengthened.

References
[1] Zhou Guangming, Zeng Jianhua, Shen Cuixin, Xu Lin. Design and implementation of online shopping system [J]. Computer Learning. 2004, (02) :40 -46.
[2] Chang Xiaoyan, Li Jiawu. Implementing online shopping system using J2EE [J]. Microcomputer Development. 2003, (09): 22-30.
[3]MENG Xi-fen. Online shopping agent prototype system design [J]. Journal of Suzhou Institute of Silk Technology. 2001, (01): 18-31.
[4] Chen Shiqiang, Xie Kunwu, Chen, Shiqiang, Xie. Design and implementation of large shopping supermarket warehouse management system [J]. Microcomputer Information. 2006, (03): 56-59.
[5] Jiang Wenxue, Wang Ping, JIANG Wen-xue, WANG Ping. Design and implementation of online shopping cart system [J]. Modern Computer (Professional Edition). 2000, (01) :66-72.
[6] Wu Yanjun, Huang Feiyue. Proficient in JSP programming technology [M]. Beijing: People's Posts and Telecommunications Press, 2003.
[7] Jiang Xiaoming, Liu Chen. Java Programming Language [M]. Beijing: Metallurgical Industry Press, 2000.

Please pay
Omitted


5. Resource download

The source code and complete paper of this project are as follows. Friends in need can click to download. If the link does not work, you can click on the card below to scan the code and download it yourself.

serial number A complete set of graduation project resources (click to download)
Source code of this project Design and implementation of online shopping system based on JSP+JavaBean+sqlserver (source code + documentation)_jsp_JavaBean_BS architecture_online shopping system.zip

6. More JAVA graduation project projects

Selected 83 sets of JAVA graduation projects - source code + complete resources of thesis

Guess you like

Origin blog.csdn.net/m0_66238867/article/details/131131789