Use JSP + MySQL to log on to and register a website.
In order to practice, I tried to create a small case of website login and registration. The interface is not very nice because it is not beautifying.
The website provides the following functions:
• Initial user registration function
• User Logon
I will show it in modules below
Registration Module
First, you need a registration interface, as shown in register. jsp:
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Then there is the registration processing page corresponding to the action, as shown in do_register.jsp:
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%><%@ page import="java.sql.*" %><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Summary:
Disadvantages:
• Database operations are not good enough, and unused resources are not closed in time. You should close unused open resources in time to release resources.
• The interface effect is not good enough, and the response output is prior to the out output.
• Database Operations are too cumbersome. You should integrate them into a toolkit dedicated to database operations to achieve good code reuse!
Logon Module
The first is the logon interface, login. jsp: Add a hyperlink to the developer (the intention is to make login. as a portal page, jsp combines login registration with one, although the two are not merged into one, and the registration interface is too simple), let's take a look.
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Next is the login information processing page, do_login.jsp:
<%@page import="java.sql.DriverManager"%><%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%><%@ page import="java.sql.*" %><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
For users who have successfully logged on, go to the logon success page login_success.jsp:
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
If a user fails to log on, send a warm page prompt, login. failed. jsp:
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Summary:
Progress:
• The session object is used to store the user's login name information and realize information interaction between pages.
• With MySQL, we have experienced the JEE mode to a certain extent.
Disadvantages:
• Code is too cumbersome and inefficient at Reuse
• The resource utilization is not high, and the unused resources should be closed in time. Although the Java Virtual Machine has an automatic garbage collection mechanism, it is best to develop a good habit!
• Poor interface control, poor experience, and lack of thinking
To be improved:
• With complicated user registration, bean-based processing is better.
• Modularization, using the MVC Concept
• Improve interface permissions to prevent leeching
• Added other functions such as uploading and downloading files to enrich website functions.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.