当前位置:网站首页>A simple hotel background management system based on jsp+servlet+mysql
A simple hotel background management system based on jsp+servlet+mysql
2022-07-25 08:07:00 【two billion sixteen million eight hundred and fifty-five thousa】
land

Chart

Add rooms

Room management

Room information editing

User list

User management

Administrator management

Administrators add

Technical description
development tool : Idea/Eclipse
database : mysql
Jar Warehouse : Ordinary jar package
Front frame :jquery/Bootstrap
Back end framework : Spring+SpringMVC+Mybatis
Information note
be based on JSP+Servlet+MySQL Simple hotel backstage management system , Include administrator role , The overall function includes user room management , User management , Administrator management, etc .
@WebServlet("/loginServlet")
public class loginServlet extends HttpServlet {
public loginServlet() {
super();
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
String managerID = request.getParameter("ManagerID");
String managePwd = request.getParameter("ManagePwd");
String validateCode = request.getParameter("validateCode");
String sessionValidateCode = (String)request.getSession().getAttribute("SESSION_VALIDATECODE");
manageDAO manageDAO = new manageDAO();
Manager login = manageDAO.login(managerID, managePwd);
if(!sessionValidateCode.equals(validateCode)){
out.print("<script type='text/javascript'>");
out.print("alert(' Error in captcha input !');");
out.print("window.location='/login.jsp';");
out.print("</script>");
return ;
}else if (login != null){
// Login successful , Use session domain attributes to record user information , Enter the main management interface
request.getSession().setAttribute("SESSION_USER", login);
response.sendRedirect("/index.jsp");
}else {
// Login failed , Error message prompt , Return to login page
out.print("<script type='text/javascript'>");
out.print("alert(' Wrong user name or password , Please re-enter !');");
out.print("window.location='/login.jsp';");
out.print("</script>");
}
}
}
@WebServlet("/ValidateCodeServlet")
public class ValidateCodeServlet extends HttpServlet {
public ValidateCodeServlet() {
super();
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("image/jpeg");
// Get binary data output stream object
ServletOutputStream out = response.getOutputStream();
// Create buffer image
int width = 60;
int height = 20;
BufferedImage imgbuf = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = imgbuf.createGraphics();
// Set the background color
g.setColor(getRandColor(200, 250));
// Set image shape, width and height
g.fillRect(0, 0, width, height);
// Randomly generated 100 Interference lines , The authentication code in the image is not easy to be detected by other programs
Random r = new Random();
g.setColor(getRandColor(160, 200));
for (int i = 0; i < 100; i++) {
int x = r.nextInt(width);
int y = r.nextInt(height);
int xl = r.nextInt(12);
int yl = r.nextInt(12);
g.drawLine(x, y, x + xl, y + yl);
}
// Randomly generated 100 A point of interruption , The verification code in the image is not easy to be detected by other analysis programs
g.setColor(getRandColor(120, 240));
for (int i = 0; i < 100; i++) {
int x = r.nextInt(width);
int y = r.nextInt(height);
g.drawOval(x, y, 0, 0);
}
// Randomly generated 0-9 Between 4 Digit verification code
g.setFont(new Font("Times New Roman", Font.PLAIN, 18));
String code = "";
for (int i = 0; i < 4; i++) {
String rand = String.valueOf(r.nextInt(10));
code += rand;
g.setColor(new Color(20 + r.nextInt(110), 20 + r.nextInt(110),
20 + r.nextInt(110)));
g.drawString(rand, 13 * i + 6, 16);
}
// Save the verification code to session in
request.getSession().setAttribute("SESSION_VALIDATECODE", code);
// Output image
ImageIO.write(imgbuf, "JPEG", out);
out.close();
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
// Get random colors in the specified range
private Color getRandColor(int fc, int bc) {
Random random = new Random();
if (fc > 255)
fc = 255;
if (fc < 0)
fc = 0;
if (bc > 255)
bc = 255;
if (bc < 0)
bc = 0;
int r = fc + random.nextInt(bc - fc);
int g = fc + random.nextInt(bc - fc);
int b = fc + random.nextInt(bc - fc);
return new Color(r, g, b);
}
}
边栏推荐
猜你喜欢

Supplementary notes on Relevant Issues of complete model group

【着色器实现Shadow投影效果_Shader效果第八篇】

交叉熵计算公式

Node+js build time server

Science: listening to music can really relieve pain. Chinese scientists reveal the neural mechanism behind it

Redis core principles

Cerebral cortex: the relationship between lifestyle and brain function in the elderly and its relationship with cognitive decline

batchnorm 和layernorm的区别

文件详细操作

Redis最佳实践
随机推荐
7.24模拟赛总结
[5g NR] UE registration rejection reason
Common commands of raspberry pie
Literature learning (part101) -- converge clustering
Dijkstra序列(暑假每日一题 5)
C# 43. 获取UDP可用端口
牛客动态规划训练
设计一个有getMin功能的栈
redis客户端工具redis-insight推荐
Raspberry Pie 3 connected to WiFi
Redis最佳实践
[QNX Hypervisor 2.2用户手册]9.3 cpu
Cache design in Web services (error allowed, error not allowed)
Introduction and installation of mongodb
Numpy learning
文献学习(part101)--CONVEX BICLUSTERING
如何仅用递归函数和栈操作逆序一个栈
yolov7 网络架构深度解析
Enq: HW - fault analysis caused by content waiting
The difference between batchnorm and layernorm