Java Web simple de login Registration

Source: Internet
Author: User
Tags import database

Java Web simple de login Registration

Recently I wrote a simple login Registration

The implementation result is as follows:

**************************************** * Part 1: effect *************************************** ****

Logon and registration page:

Login successful and registration successful page:

(Return to the logon page after successful registration)

************************************ Part 2: implement *************************************** *****

 

Login and registration are two basic functions that can be expanded on this basis,

Logon registration is implemented in the following three parts,

Basic java interfaces and Classes

Mysql database connection

Jsp and servlet

1. First, database creation and Connection

(Data must be submitted to the server for login and registration, and the server takes the remaining database data for related operations)

Taking my program as an example, first create a user Table (student user) in the Database, Database: Mysql3 Table: student

Set two attributes: String name and String password;

Initialize some data.

After the database and related tables are processed, create a web project in MyEclipse. Other code is written on this platform (you can also use eclipse)

Create a new package cn.edu. hpu. model name (custom servlet jsp project name class interfence name is created below)

1. Used to write the student class, corresponding to the table created,

2. Establish a database connection so that the server can query and use the database data.

(Database connections are divided into three parts: loading drivers; Creating connection objects; and other related objects; and closing opened data streams)

3. New Package cn.edu. hpu. test write test connection code, in/test/WebRoot/WEB-INF/lib import database connection *. jar File

//////////////////////////////////////// //////////////////////////////////

 

Create cn.edu. hpu. service

Write an interface in the package, and add ckeckLogin two methods to register 'logon

Create a class to implement the interface

//////////////////////////////////////// //////////////////////////////////////// //

Test the above two methods

1.

2.

Related Verification

Finally, create jsp and the corresponding servlet

The Code is as follows: note that changing pageEncoding to UTF-8 supports Chinese characters to prevent garbled characters.

/////////////////////

***/////

//////////////////////////////////////// ////////////////////////////////////////

/////

//////////////////////////////////////// ////////////////////////////

Servlet:

//////////////////////////////////////// //////////////////////////////////

Xml files are automatically generated in Myeclipse. Other platforms may need to write them by themselves.

The Code is as follows:

 

A series of errors or exceptions may occur due to incorrect path or case sensitivity. The above code is free of errors. Pay attention to the code writing standards to develop a good style.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.