Javaweb simple de sign-in registration

Source: Internet
Author: User

Recently wrote a simple login to register

The implementation results are as follows:

The first part: effect *******************************************

Login and Registration interface:

Login success and Registration successful interface:

(Login interface is returned after successful registration)

Part Two: Realizing ********************************************


Login and registration is the two most basic functions, can be based on this to expand,

The implementation of login registration, mainly divided into the following 3 parts,

Java Foundation interfaces and classes

Database Mysql Connection

JSP and Servlet

1. First, create and connect the database

(Login and registration to submit data to the server, the server to take the rest of the database data related operations)

Take my program as an example first set up a user table in the database (student user), Database:mysql3 table:student

Set two properties of String name; String password;

Initialize some of the data.

After the database and related tables are processed, create a Web project project in MyEclipse, and other code is written on this platform (also available in eclipse)

New Package Cn.edu.hpu.model name customization (following new servlet JSP project name class interfence name customization)

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

2. Then establish a connection to the database so that the server query uses the database data

(The database connection is divided into three parts, one is to load the driver two is to create the connection object, and other related objects three is to close the Open data stream)

3. Create a new package Cn.edu.hpu.test write the code of the test connection, import the *.jar file of the database connection in/test/webroot/web-inf/lib

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


New Package Cn.edu.hpu.service

Write an interface in the package, and two methods add ckecklogin corresponding registration ' login

Create a new class that implements an interface

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



Test the above two methods

1.

2.

Related validation

Finally, create the JSP and the corresponding servlet

The code is as follows: note Change pageencoding to Utf-8 support Chinese to prevent garbled characters

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

***/////

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

/////

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

Servlet:

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

XML files are automatically generated in MyEclipse, and other platforms may have to write their own

The code is as follows:


Due to the path problem, casing problems, such as writing irregularities may lead to a series of errors, exceptions, the above code can be used without errors, please pay attention to code writing specifications, form a good style


Javaweb simple de sign-in registration

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.