当前位置:网站首页>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);
}
}
边栏推荐
- MVC mode three-tier architecture
- 由两个栈组成的队列
- Vscode remote connection server, switch to go version
- Mysql-5.7 installation
- RK3399开发板I2C4挂载EEPROM实例
- How should enterprise users choose aiops or APM?
- 文件详细操作
- P1047 [noip2005 popularization group t2] tree outside the school gate
- The 17th revitalization cup computer programmer (cloud computing platform operation and development) finals
- IoT物联网嵌入式设备中30种常见传感器模块简介及原理讲解
猜你喜欢

交叉熵计算公式

Advanced C language (XIII) - Example Analysis of dynamic memory management

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

Introduction and principle explanation of 30 common sensor modules in IOT embedded devices

Introduction and installation of mongodb
Cache design in Web services (error allowed, error not allowed)

Introduction to machine learning (I): understanding maximum likelihood estimation in supervised learning

Test the mock data method of knowing and knowing

How does MTK change the boot logo?

Svg creative underline style JS special effect
随机推荐
Machine learning theory and case analysis (Part1) -- Fundamentals of machine learning
C# 43. 获取UDP可用端口
If Debian infringes the rust trademark, will it be exempted by compromising and renaming?
eval与assert一句话木马分析
[5g NR] UE registration rejection reason
Leetcode (Sword finger offer) - 04. search in two-dimensional array
If there is complex select nesting in the SQL of the flick CDC, when it encounters the binlog of delete, it will
A simple SQL injection shooting range exercise
Machine learning theory and case analysis (Part2) -- Regression
File details
如何仅用递归函数和栈操作逆序一个栈
Can Flink's current capabilities support the synchronization of a table from source (MySQL) to sink (MySQL) to separate databases and tables
Node+js build time server
Redis分片集群
Learn when playing No 5 | human high quality examination, right here →
JS cool rolling picture deformation animation JS special effects
Common commands of raspberry pie
IoT物联网嵌入式设备中30种常见传感器模块简介及原理讲解
A queue of two stacks
Learn when playing No 6 | the magic of document library lies in