Web project design and development —————— DBHelper testing

Source: Internet
Author: User

There are three files in this dbhelper test.

One is dbhelper Java file, because of too much code is not described.

The other two are JSP files, one for the index.jsp code for the login page

<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%>

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<title> Login Page </title>

<body>
<form name= "F1" action= "login.jsp" >
User name: <input type= "text" name= "UID" ><br>
Password: <input type= "password" name= "pwd" ><br>
<input type= "Submit" value= "Login" >
</form>
</body>

The second is the login.jsp code for the validation page

<% @page import= "Java.sql.ResultSet"%>
<%@ page language= "java" import= "java.util.*,dbhelper.*"
pageencoding= "UTF-8"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<title>my JSP ' login.jsp ' starting page</title>

<body>
<%
String sql= "SELECT * from user where username=? and password=? ";
String uid=request.getparameter ("UID");
String pwd=request.getparameter ("pwd");
Object[] Params=new object[]{uid,pwd};
ResultSet rs= Dbhelper.getresultset (SQL, params);
if (Rs.next ())
Out.print ("Landing success");
Else
Out.print ("Login Failed");
Rs.close ();
%>
</body>

According to two code connection database to authenticate the user name password, there are many noteworthy in the code writing, because the novice writing may have a lot of errors, and in the teacher's hands-on teaching still a little bit of error such as: Bad environment configuration is incorrect, code is not written correctly I think in the course of learning Web project design and development should not only consolidate the previous Web page design knowledge, but also to self-study, to learn good computer language for the purpose, later engaged in the computer industry is proud.

Web project design and development —————— DBHelper testing

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.