基于JSP servlet mysql 的登陆页面
数据库中建表:

login.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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登陆</title>
<style>
#top{
width: 1024px;
height: 207px;
background: url("image/topbg.gif") no-repeat;
margin: auto;
}
#tablee{ width: 1024px;
height: 340px;
padding-top:15px;
margin: auto;
}
/*table设置外围边框,设置table固定不动*/
table{ width:600px;
table-layout:fixed;
margin:auto; }
.inputt{
width:95%;
}
#tdd{ text-align:center; }
.tr30{
height:30px;
}
.tr50{
height:50px;
}
#tdd2{
text-align:center;
font-size:13px;
color:gray;
}
.anniu{
border: 1px solid #cccbcb;
border-radius: 7px;
font-size: 1em;
font-weight: bold;
color: #fff;
background: #0dbfdd;
}
#bottom{
width: 1024px;
height: 55px;
background: url("image/end.png") no-repeat;
margin:auto;
text-align: center;
padding-top: 12px;
line-height:20px;
font-size: 15px;
font-family: 宋体;
}
#huixian{
text-align: center;
font-size: 13px;
color:red;
}
</style> </head>
<body >
<form action="Login" method="post" name="frmLogin" >
<div class="tanlee">
<div id="top"></div>
<div id="tablee" >
<table cellpadding="0px" cellspacing="0px " >
<tr class="tr30" ><td id="huixian" colspan="3">${error}
</td>
</tr>
<tr class="tr50">
<td style="text-align:center"> 用户:
</td>
<td ><input class="inputt" id="Uidid" type="text" name="uid" onfocus="ShowTips('remind1')" onblur="Checkid()"/>
</td>
<td> <%-- input 的值弹出提醒--%>
<span id="remind1" ></span>
</td>
</tr>
<tr class="tr50">
<td style="text-align:center;" > 密码:
</td>
<td><input class="inputt" id="passid" type="password" name="password" onfocus="ShowTips('remind2')" onblur="Checkpass()" />
</td>
<td> <%-- input 的值弹出提醒--%>
<span id="remind2" ></span>
</td>
<tr class="tr50">
<td id="tdd" colspan="3">
<input type="submit" class="anniu" value=" 登陆 " />
<input type="button" class="anniu" value=" 重置 " onclick="resetValue()"/>
</td>
</tr>
<tr class="tr30">
</tr>
<tr class="tr30"> <td id="tdd2" colspan="3">忘记密码?请联系管理员!</td>
</tr>
</table>
</div>
<div id="bottom">
©CopyRight ****-****.Net Inc All Rights Reserved. ********版权所有
</div>
</div>
</form>
</body>
</html>
User.java
public class User {
private String uid;
private String uname;
private String password;
private String ulimit;
public String getuid() {
return uid;
}
public void setuid(String uid){
uid=this.uid;
}
public String getuname(){
return uname;
}
public void setuname(String uname){
this.uname=uname;
}
public String getpassword(){
return password;
}
public void setpassword(String password){
this.password=password;
}
public String getlimit(){
return ulimit;
}
public void setulimit(String ulimit){
this.ulimit=ulimit;
}
}
}
Userdao.java
public class Userdao {
public User loginIN(String uid,String password){
User newuser=null;
DButils db=new DButils();
try {
String sql="select *from users where uid=? and upassword=?";
Object param[]={uid,password};
db.doPost(sql, param);
ResultSet rs=db.getResultSet();
if(rs.next()){
newuser=new User();
newuser.setuid(rs.getString("uid"));
newuser.setuname(rs.getString("uname"));
newuser.setpassword(rs.getString("upassword"));
newuser .setulimit(rs.getString("ulimit"));
rs.close();
}else System.out.print("登陆失败");
} catch (Exception e) {
new RuntimeException("登陆异常!");
}
return newuser;
}
}
Loginservlet.java
public class Loginservlet extends HttpServlet {
private static final long serialVersionUID=1L;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String id=request.getParameter("uid");
String password=request.getParameter("password");
Userdao userdao=new Userdao();
User user= userdao.loginIN(id, password);
if(user!=null){
HttpSession session=request.getSession();
session.setAttribute("currentUser", user);
response.sendRedirect("succ/scuu2.jsp");
}
else {
request.setAttribute("error", "您输入的凭证有误!");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
}
}
基于JSP servlet mysql 的登陆页面的更多相关文章
- 基于jsp+servlet图书管理系统之后台万能模板
前奏: 刚开始接触博客园写博客,就是写写平时学的基础知识,慢慢发现大神写的博客思路很清晰,知识很丰富,非常又价值,反思自己写的,顿时感觉非常low,有相当长一段时间没有分享自己的知识.于是静下心来钻研 ...
- 基于JSP+SERVLET的新闻发布系统(一)
本系统使用的是基于JSP+SERVLET+TOMCAT6 数据库使用的是MYSQL IDE是MYECLIPSE8.5,页面编辑使用的是百度的ueditor,比较适合咱国人 采用MVC模式,使用的关键技 ...
- 基于jsp+servlet图书管理系统之后台用户信息插入操作
前奏: 刚开始接触博客园写博客,就是写写平时学的基础知识,慢慢发现大神写的博客思路很清晰,知识很丰富,非常又价值,反思自己写的,顿时感觉非常low,有相当长一段时间没有分享自己的知识.于是静下心来钻研 ...
- 基于jsp+servlet图书管理系统之后台用户信息删除操作
上一篇的博客写的是修改操作,且附有源码和数据库,这篇博客写的是删除操作,附有从头至尾写的代码(详细的注释)和数据库! 此次删除操作的源码和数据库:http://download.csdn.net/de ...
- jsp+servlet+mysql 实现简单的银行登录转账功能
jsp+servlet+mysql 实现简单的银行登录转账功能 [前期的准备] html(登录界面),servlet(处理业务逻辑),jsp(主要实现界面),mysql(实现与数据库的简单的交互)先从 ...
- 基于JSP+Servlet开发手机销售购物商城系统(前台+后台)源码
基于JSP+Servlet开发手机销售购物商城系统(前台+后台) 开发环境: Windows操作系统 开发工具:Eclipse/MyEclipse+Jdk+Tomcat+MySQL数据库 运行效果图: ...
- 基于JSP+Servlet开发高校社团管理系统(前台+后台) 源码
基于JSP+Servlet开发高校社团管理系统(前台+后台): 开发环境: Windows操作系统 开发工具:Eclipse/MyEclipse+Jdk+Tomcat+MYSQL数据库 运行效果 ...
- jsp+servlet+mysql简单实现用户登陆注册
原码,项目中遇到的错误,解决方法,文章最后有链接可以获取 项目简介 *有的网友说在修改和删除时会触发error,建议各位不要去把用户名命名为中文! 功能描述 登陆,注册,用户一览表,修改,删除,添加, ...
- (详细)Eclips+jsp+servlet+mysql+登录实例+源代码
欢迎任何形式的转载,但请务必注明出处. 该教程较全,从软件的安装以及相关的环境配置我都放置了相关教程的链接,读者可直接点击进入.自己写电商网站作业时查找了很多资料,但都不是很全,所以趁着寒假写了这份教 ...
随机推荐
- 从零开始在iPhone上运行视频流实时预测模型应用,只需10步
1、买一台苹果电脑,建议MacBook Pro. 2、安装Xcode. 3、克隆TensorFlow:https://github.com/tensorflow/tensorflow.git 4、下载 ...
- 编程总结5&学习总结
基础题目 请在第一周作业的基础上,继续完成:找出给定的文件中数组的最大值及其对应的最小下标(下标从0开始).并将最大值和对应的最小下标数值写入文件. 输入:请建立以自己英文名字命名的txt文件,并输入 ...
- c# 枚举安卓系统中所有目录及文件名
using Android.App; using Android.Widget; using Android.OS; using System.Runtime.InteropServices; nam ...
- LVS详细介绍以及遇到的坑
LVS详细介绍以及遇到的坑 一,概述 本文介绍了我搭建LVS集群的步骤,并且在使用LVS(Linux Virtual Server)过程中遇到的问题和坑, 二,LVS简单介绍 大家都知道,LVS中文意 ...
- 我发起了一个 ILBC 的 子项目 EScript
ILBC 见 <ILBC 规范> https://www.cnblogs.com/KSongKing/p/10354824.html 今天装了个 VsCode , 听说 VsCode ...
- Panel 中加载窗体
pnlMain.Controls.Clear(); ControlAnalyzer1 CA1 = new ControlAnalyzer1(); CA1.TopLevel = false; CA1.S ...
- MapReduce作业的工作原理
在Hadoop中,我们可以通过Job对象的submit()方法来运行MapReduce作业,也可以调用waitForCompletion()用于提交以前没有提交过的作业,并等待它的完成.其中,subm ...
- 用Python抓取网页并解析
软件版本 python:2.7.12 网页抓取库 网页抓取库为requests, github地址为:https://github.com/requests/requests, 文档地址为:http: ...
- 将mnist获得的数据还原成图片形式
MNIST是一个手写数字数据集,里面所包含的数据元素是类似于一个1×784矩阵和1×10矩阵的结构,那么,如何将这些数据元素转化为更加直观的图像呢?通过以下python代码,可以实现. from PI ...
- 【读后感】读《漫谈“大学生的四个learn”》之后有感
在看完<许纪霖教授在上海财经大学演讲——漫谈“大学生的四个Learn”>(下问简称<四l>)之后突然有点话想说.其实我对这篇文章有感的,所以想写这篇文章来说说看,我对四个lea ...