package com.Servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import dao.DBConnection;
public class xiugaimima extends HttpServlet {
/**
* Constructor of the object.
*/
public xiugaimima() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html charst=utf-8");
PrintWriter out = response.getWriter();
//获得在修改页面用户提交的信息
HttpSession usersession=request.getSession();
String username=usersession.getAttribute("username").toString();//获得用户名
String xuanze=usersession.getAttribute("xuanze").toString();//获得身份
String nowpwd=request.getParameter("nowpwd");//获得现在密码
String newpwd=request.getParameter("newpwd");//获得第一次输入的心密码
String repwd=request.getParameter("repwd");//获得第二次输入的密码
//数据库操作
Connection con=null;
PreparedStatement ps=null;
ResultSet rs=null;
try {
con=DBConnection.getConnection();
if(xuanze.toString()=="adm"){
ps=con.prepareStatement("select * from managerinfo where MUSERNAME=?");
}else
{
ps=con.prepareStatement("select * from empinfo where EMPNAME=?");
}
//给?赋值
ps.setString(1,username);
//ps.setString(2, password);
rs=ps.executeQuery();
while(rs.next())
{
String dbpassword;//存储由数据库取出的密码
if("adm".equals(xuanze))
{
//dbpassword=rs.getString("MPASSWORD");
dbpassword=rs.getString(2);
}else
{
dbpassword=rs.getString(9);
}
if(dbpassword.equals(nowpwd))
{
out.println("现在密码输入不正确!");
}
}
//ps.close();
//rs.close();
ps=null;
rs=null;
if(newpwd.equals(repwd))
{
if("adm".equals(xuanze))
{
//修改管理员密码
ps=con.prepareStatement("update managerinfo set MPASSWORD=?where MUSERNAME=?");
ps.setString(1,newpwd);
ps.setString(2,username);
ps.executeUpdate();
//out.println("修改成功!");
System.out.println("修改成功!");
}
else
{
//修改职员密码
//System.out.println("");
ps=con.prepareStatement("update empinfo set EMPPASSWORD=?where EMPNAME=?");
ps.setString(1,newpwd);
ps.setString(2,username);
ps.executeUpdate();
response.sendRedirect("success.jsp");
}
}
else
{
response.sendRedirect("xiugaiyemian.jsp");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
if(rs!=null)
{
try {
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
rs=null;
}
if(ps!=null)
{
try {
ps.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ps=null;
}
if(con!=null)
{
try {
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
con=null;
}
}
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Renshiguanli.rar (99个子文件)
Renshiguanli
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 500B
org.eclipse.jdt.core.prefs 330B
src
dao
depth.java 517B
BaseDao.java 4KB
emp.java 499B
DBConnection.java 1KB
com
dao
impl
depthimpl.java 3KB
empimpl.java 4KB
tools
Bumen.java 722B
Zhiwu.java 405B
ShowView.java 2KB
Servlet
BumenshanchuServlet.java 1KB
RenshichaxunServlet2.java 3KB
RenshixiugaiServlet.java 2KB
RenshishanchuServlet.java 2KB
BumenchaxunServlet2.java 2KB
BumentianjiaServlet.java 1KB
xiugaimima.java 5KB
BumenchaxunServlet.java 3KB
LoginPage.java 4KB
RenshichaxunServlet.java 3KB
BumenxiugaiServlet.java 1KB
RenshitianjiaServlet.java 2KB
entity
depthinfo.java 732B
empinfo.java 2KB
LogInfo.java 667B
util
ObjectFactory.java 1KB
ReadPro.java 640B
db.properties 119B
.project 1KB
WebRoot
css
data.css 236B
pic
Security.jpg 46KB
menu3.jpg 13KB
menu2.jpg 13KB
log.png 3KB
menu5.jpg 12KB
logo1a9519.jpg 18KB
menu1.jpg 11KB
menu4.jpg 13KB
images
tableHead.jpg 8KB
下载.jpg 4KB
META-INF
MANIFEST.MF 36B
bumenxiutian.jsp 3KB
WEB-INF
web.xml 5KB
classes
dao
emp.class 433B
depth.class 443B
BaseDao.class 4KB
DBConnection.class 2KB
com
dao
impl
empimpl.class 5KB
depthimpl.class 4KB
tools
Zhiwu.class 751B
ShowView.class 2KB
Bumen.class 1KB
Servlet
RenshichaxunServlet2.class 3KB
RenshitianjiaServlet.class 2KB
RenshishanchuServlet.class 2KB
RenshixiugaiServlet.class 2KB
BumenxiugaiServlet.class 2KB
BumenchaxunServlet2.class 3KB
LoginPage.class 4KB
RenshichaxunServlet.class 3KB
BumentianjiaServlet.class 2KB
xiugaimima.class 4KB
BumenchaxunServlet.class 3KB
BumenshanchuServlet.class 2KB
entity
LogInfo.class 1KB
empinfo.class 3KB
depthinfo.class 1KB
util
ObjectFactory.class 2KB
ReadPro.class 752B
db.properties 119B
lib
js
WdatePicker.js 7KB
first.jsp 8KB
xiugaiyemian.jsp 2KB
index.jsp 3KB
xiutian.jsp 6KB
error.jsp 827B
bumenchaxun.jsp 4KB
renshichaxun.jsp 5KB
zhanghaoxinxi.jsp 1KB
datepicker
WdatePicker.js 7KB
config.js 225B
lang
zh-cn.js 383B
en.js 415B
zh-tw.js 382B
skin
datePicker.gif 1KB
whyGreen
img.gif 2KB
datepicker.css 5KB
bg.jpg 307B
WdatePicker.css 158B
default
img.gif 2KB
datepicker.css 4KB
My97DatePicker.htm 1KB
calendar.js 22KB
success.jsp 850B
.mymetadata 309B
.classpath 468B
.myeclipse
共 99 条
- 1
资源评论
御道御小黑
- 粉丝: 61
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 2-08 http协议和nginx入门
- 基于Java的ADmobile ADSuyi-Flutter插件广告聚合SDK设计源码
- mkl-2021.1.1-py2.py3-none-manylinux1-x86-64.whl
- Drivingnotmessage.apk
- mkl-2021.4.0-py2.py3-none-manylinux1-x86-64.whl
- wiliwili-yoga.zip
- 项目计划书.doc
- mkl-2021.2.0-py2.py3-none-manylinux1-x86-64.whl
- 情侣恋爱相册记录-游玩生活
- 毕业设计项目源码-使用Matlab基于蚁群算法的三维路径规划算法实现.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功