package com.servlet;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
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 com.bean.DB;
import com.bean.User;
public class userServlet extends HttpServlet{
private static final long serialVersionUID = 1L;
public static Statement stmt =DB.createStmt(DB.getConn()); //查询
public static ResultSet rs = null; //得到的数据
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession(true);
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
try {
String username= request.getParameter("username");
String password= request.getParameter("password");
String per= request.getParameter("per");
String id= request.getParameter("id");
String type= request.getParameter("type");
type=(type==null?"list":type);
if(type.equals("login")){
rs = DB.executeQuery(stmt, "select * from user where password='"+password+"' and username='"+username+"' and per='"+per+"' ");
User u=new User();
while(rs.next()){
u.setUsername(rs.getString("username"));
u.setPassword(rs.getString("password"));
u.setPer(rs.getString("per"));
u.setId(Integer.parseInt(rs.getString("id")));
}
if(u.getId()>0){
session.setAttribute("user", u);
response.sendRedirect(basePath+"index.jsp");
}else{
response.sendRedirect(basePath+"login.jsp");
}
}else if(type.equals("update")){
stmt.executeUpdate("update user set username='"+username+"',password='"+password+"',per='"+per+"' where id='"+id+"' ");
response.sendRedirect(basePath+"index.jsp");
}else if(type.equals("list")){
rs = DB.executeQuery(stmt, "select * from user ");
List<User> listuser=new ArrayList<User>();
while(rs.next()){
User u=new User();
u.setUsername(rs.getString("username"));
u.setPassword(rs.getString("password"));
u.setPer(rs.getString("per"));
u.setId(Integer.parseInt(rs.getString("id")));
listuser.add(u);
}
session.setAttribute("listuser", listuser);
}else if(type.equals("del")){
stmt.executeUpdate("delete from user where id='"+id+"' ");
response.sendRedirect(basePath+"index.jsp");
}else if(type.equals("add")){
if(username.length()>0 && password.length()>0 && per.length()>0){
stmt.executeUpdate("insert into user(username,password,per) values('"+username+"','"+password+"','"+per+"')");
String url= request.getParameter("url");
if(url!=null){
response.sendRedirect(basePath+url);
}else{
response.sendRedirect(basePath+"urseeditlist.jsp");
}
}else{
response.sendRedirect(basePath+"register.jsp");
}
}
} catch (SQLException e) {}
}
public userServlet() {
super();
}
public void destroy() {
super.destroy();
}
public void init() throws ServletException {
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
可二次开发MYSQLbishe012.zip
共165个文件
gif:89个
jpg:14个
jsp:12个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 15 浏览量
2024-04-18
01:41:57
上传
评论
收藏 1.87MB ZIP 举报
温馨提示
【项目资源】:包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。【项目质量】:所有源码都经过严格测试,可以直接运行。功能在确认正常工作后才上传。【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。【附加价值】:项目具有较高的学习借鉴价值,也可直接拿来修改复刻。对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。【沟通交流】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。鼓励下载和使用,并欢迎大家互相学习,共同进步。
资源推荐
资源详情
资源评论
收起资源包目录
可二次开发MYSQLbishe012.zip (165个子文件)
caseServlet.class 5KB
userServlet.class 5KB
DB.class 3KB
Case.class 2KB
User.class 1KB
.classpath 2KB
org.eclipse.wst.common.component 483B
org.eclipse.wst.jsdt.ui.superType.container 49B
datepicker.css 5KB
datepicker.css 5KB
i-heart-ny.css 4KB
tab.css 3KB
calendar.css 3KB
dashboard.css 2KB
iframe.css 2KB
edu.css 692B
all.css 548B
WdatePicker.css 158B
manage.gif 131KB
manages.gif 128KB
login_09.gif 22KB
login_04.gif 19KB
login_06.gif 14KB
login_03.gif 5KB
main_08.gif 5KB
left_tree.gif 5KB
login_08.gif 5KB
main_11.gif 4KB
main_12.gif 3KB
login_07.gif 2KB
main_21.gif 2KB
main_31.gif 2KB
main_28.gif 2KB
main_31_1.gif 2KB
main_29_1.gif 2KB
main_26_1.gif 2KB
main_26.gif 2KB
main_06.gif 2KB
main_07.gif 2KB
img.gif 2KB
img.gif 2KB
middle_yhzc_01.gif 1KB
login3.gif 1KB
tab_05.gif 1KB
tab_03.gif 1KB
tab_07.gif 1KB
datePicker.gif 1KB
g_page.gif 1024B
005.gif 1024B
dl.gif 984B
back.gif 749B
next.gif 745B
last.gif 741B
go.gif 736B
first.gif 736B
main_45.gif 726B
main_01.gif 682B
calendar-icon.gif 625B
main_09.gif 617B
sumbit_4.gif 610B
311.gif 608B
a.gif 556B
sumbit_5.gif 550B
i-heart-ny-icon.gif 546B
calendar-valid.gif 504B
calendar-td.gif 498B
i-heart-ny-invalid.gif 494B
login2.gif 489B
main_23.gif 420B
dashboard-icon.gif 406B
main_16.gif 405B
main_49.gif 400B
i-heart-ny-active.gif 380B
i-heart-ny-inactive.gif 378B
calendar-prev.gif 376B
calendar-next.gif 374B
083.gif 341B
114.gif 337B
main_51.gif 322B
main_47.gif 309B
main_14.gif 309B
002.gif 308B
tab_14.gif 263B
calendar-hilite.gif 242B
middle_tjkc_993.gif 238B
001.gif 213B
dashboard-next.gif 188B
dashboard-prev.gif 188B
arrow_082.gif 181B
tab_20.gif 164B
main_04.gif 140B
tab_22.gif 131B
037.gif 118B
tab_16.gif 112B
tab_12.gif 112B
middle_tjkc_03.gif 110B
a1.gif 100B
main_38.gif 97B
main_40.gif 91B
login1.gif 89B
共 165 条
- 1
- 2
资源评论
CyMylive.
- 粉丝: 7285
- 资源: 4万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 数据库管理工具:dbeaver-ce-23.3.1-stable.x86-64.rpm
- AndroidOCR源码.zip
- 数据库管理工具:dbeaver-ce-23.3.0-x86-64-setup.exe
- 数据库管理工具:dbeaver-ce-23.3.0-stable.x86-64.rpm
- 数据库管理工具:dbeaver-ce-23.3.0-macos-x86-64.dmg
- 数据库管理工具:dbeaver-ce-23.3.0-macos-aarch64.dmg
- 数据库管理工具:dbeaver-ce-23.2.5-stable.x86-64.rpm
- 数据库管理工具:dbeaver-ce-23.2.5-macos-x86-64.dmg
- C语言面试应用详解教程
- 数据库管理工具:dbeaver-ce-23.2.5-macos-aarch64.dmg
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功