Source code acquisition : My blog Homepage " resources " Download in !

Project introduction

This project is based on Servlet+JSP Cinema ticketing system based on , There are two roles: administrator and member .

Administrator privileges include :

Modify login password
Film category management
Film information management
Member information management
Order information management
Message management

Membership rights include :

Member registration
Member login
Browse movies
My shopping cart
My order
Message Board

Environmental needs

1. Operating environment : Better be java jdk 1.8, We run on this platform . Other versions are theoretically OK .
2.IDE environment :IDEA,Eclipse,Myeclipse Fine . recommend IDEA;
3.tomcat environment :Tomcat 7.x,8.x,9.x Both versions are available
4. hardware environment :windows 7/8/10 1G Memory above ; perhaps Mac OS;
5. database :MySql 5.7 edition ;
6. whether Maven project : no ; Check whether the source code directory contains pom.xml; If included , Is maven project , Otherwise, it is not maven project

Technology stack

Servlet,JSP,JDBC,MySQL5.7,Tomcat8

instructions

1. use Navicat Or other tools , stay mysql Create a database with the corresponding name in , And import the sql file ;
2. use IDEA/Eclipse/MyEclipse Import project , Then run ;
3. In the project src/com/dao/DB.java Change the database configuration in the configuration file to your own configuration ;
4. Run project , Enter in the browser localhost:8080/goupiao
administrator account / password :admin/admin
Member account number / password :zhangsan/123456

 

 

 

 

 

User management control layer : 
public class user_servlet extends HttpServlet { public void
service(HttpServletRequest req,HttpServletResponse res)throws ServletException,
IOException { String type=req.getParameter("type");
if(type.endsWith("userReg")) { userReg(req, res); }
if(type.endsWith("userLogout")) { userLogout(req, res); }
if(type.endsWith("userEditMe")) { userEditMe(req, res); }
if(type.endsWith("userMana")) { userMana(req, res); }
if(type.endsWith("userDel")) { userDel(req, res); } } public void
userReg(HttpServletRequest req,HttpServletResponse res) { String
id=String.valueOf(new Date().getTime()); String
loginname=req.getParameter("loginname"); String
loginpw=req.getParameter("loginpw"); String name=req.getParameter("name");
String del="no"; String s=liuService.panduan_zhanghao(loginname);
if(s.equals("yizhan")) { req.setAttribute("message", " Account number has been occupied , Please enter another account ");
req.setAttribute("path", "site/userreg/userreg.jsp"); String targetURL =
"/common/success.jsp"; dispatch(targetURL, req, res); } else { String
sql="insert into t_user values(?????)"; Object[]
params={id,loginname,loginpw,name,del}; DB mydb=new DB(); mydb.doPstm(sql,
params); mydb.closed(); req.setAttribute("message", " login was successful , Please login ");
req.setAttribute("path", "site/default.jsp"); String targetURL =
"/common/success.jsp"; dispatch(targetURL, req, res); } } public void
userLogout(HttpServletRequest req,HttpServletResponse res) throws
ServletException, IOException { HttpSession session=req.getSession();
session.setAttribute("userType", null); session.setAttribute("user", null);
req.setAttribute("message", " Successfully quit the system "); req.setAttribute("path",
"site/default.jsp"); String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res); } public void userEditMe(HttpServletRequest
req,HttpServletResponse res) { String id=req.getParameter("id"); String
loginname=req.getParameter("loginname"); String
loginpw=req.getParameter("loginpw"); String name=req.getParameter("name");
String sql="update t_user set loginname=?loginpw=?name=? where id=?";
Object[] params={loginname,loginpw,name,id}; DB mydb=new DB(); mydb.doPstm(sql,
params); mydb.closed(); req.setAttribute("message", " Successfully modified , Take effect after re waiting ");
req.setAttribute("path", "site/default.jsp"); String targetURL =
"/common/success.jsp"; dispatch(targetURL, req, res); } public void
userMana(HttpServletRequest req,HttpServletResponse res) throws
ServletException, IOException { List userList=new ArrayList(); String
sql="select * from t_user where del='no'"; Object[] params={}; DB mydb=new
DB(); try { mydb.doPstm(sql, params); ResultSet rs=mydb.getRs();
while(rs.next()) { Tuser user=new Tuser(); user.setId(rs.getString("id"));
user.setLoginname(rs.getString("loginname"));
user.setLoginpw(rs.getString("loginpw"));
user.setLoginpw(rs.getString("loginpw")); user.setName(rs.getString("name"));
userList.add(user); } rs.close(); } catch(Exception e) { e.printStackTrace(); }
mydb.closed(); req.setAttribute("userList", userList);
req.getRequestDispatcher("admin/user/userMana.jsp").forward(req, res); } public
void userDel(HttpServletRequest req,HttpServletResponse res) throws
ServletException, IOException { String id=req.getParameter("id"); String
sql="update t_user set del='yes' where id=?"; Object[] params={id}; DB mydb=new
DB(); mydb.doPstm(sql, params); mydb.closed(); req.setAttribute("msg",
" User information deletion completed "); String targetURL = "/common/msg.jsp"; dispatch(targetURL, req,
res); } public void dispatch(String targetURI,HttpServletRequest
request,HttpServletResponse response) { RequestDispatcher dispatch =
getServletContext().getRequestDispatcher(targetURI); try {
dispatch.forward(request, response); return; } catch (ServletException e) {
e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public
void init(ServletConfig config) throws ServletException { super.init(config); }
public void destroy() { } }
Order management control layer :
public class order_servlet extends HttpServlet { public void
service(HttpServletRequest req,HttpServletResponse res)throws ServletException,
IOException { String type=req.getParameter("type");
if(type.endsWith("orderMana")) { orderMana(req, res); }
if(type.endsWith("orderDel")) { orderDel(req, res); }
if(type.endsWith("orderShouli")) { orderShouli(req, res); } } public void
orderMana(HttpServletRequest req,HttpServletResponse res) throws
ServletException, IOException { List orderList=new ArrayList(); String
sql="select * from t_order order by zhuangtai desc"; Object[] params={}; DB
mydb=new DB(); try { mydb.doPstm(sql, params); ResultSet rs=mydb.getRs();
while(rs.next()) { Torder order=new Torder(); order.setId(rs.getString("id"));
order.setBianhao(rs.getString("bianhao"));
order.setShijian(rs.getString("shijian"));
order.setZhuangtai(rs.getString("zhuangtai"));
order.setSonghuodizhi(rs.getString("songhuodizhi"));
order.setFukuanfangshi(rs.getString("fukuanfangshi"));
order.setJine(rs.getInt("jine")); order.setUser_id(rs.getString("user_id"));
orderList.add(order); } rs.close(); } catch(Exception e) { e.printStackTrace();
} mydb.closed(); req.setAttribute("orderList", orderList);
req.getRequestDispatcher("admin/order/orderMana.jsp").forward(req, res); }
public void orderDel(HttpServletRequest req,HttpServletResponse res) throws
ServletException, IOException { String id=req.getParameter("id"); String
sql="delete from t_order where id=?"; Object[] params={id}; DB mydb=new DB();
mydb.doPstm(sql, params); mydb.closed(); req.setAttribute("msg", " Information deletion completed ");
String targetURL = "/common/msg.jsp"; dispatch(targetURL, req, res); } public
void orderShouli(HttpServletRequest req,HttpServletResponse res) throws
ServletException, IOException { String id=req.getParameter("id"); String
sql="update t_order set zhuangtai='yes' where id=?"; Object[] params={id}; DB
mydb=new DB(); mydb.doPstm(sql, params); mydb.closed(); req.setAttribute("msg",
" Order acceptance completed "); String targetURL = "/common/msg.jsp"; dispatch(targetURL, req, res);
} public void dispatch(String targetURI,HttpServletRequest
request,HttpServletResponse response) { RequestDispatcher dispatch =
getServletContext().getRequestDispatcher(targetURI); try {
dispatch.forward(request, response); return; } catch (ServletException e) {
e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public
void init(ServletConfig config) throws ServletException { super.init(config); }
public void destroy() { } }
Commodity management control layer :
public class goods_servlet extends HttpServlet { public void
service(HttpServletRequest req,HttpServletResponse res)throws ServletException,
IOException { String type=req.getParameter("type");
if(type.endsWith("goodsAdd")) { goodsAdd(req, res); }
if(type.endsWith("goodsMana")) { goodsMana(req, res); }
if(type.endsWith("goodsDel")) { goodsDel(req, res); }
if(type.endsWith("goodsDetailHou")) { goodsDetailHou(req, res); }
if(type.endsWith("goodsAll")) { goodsAll(req, res); }
if(type.endsWith("goodsByCatelog")) { goodsByCatelog(req, res); }
if(type.endsWith("goodsDetailQian")) { goodsDetailQian(req, res); } } public
void goodsAdd(HttpServletRequest req,HttpServletResponse res) { String
id=String.valueOf(new Date().getTime()); String
fangyingshi=req.getParameter("fangyingshi"); String
catelog_id=req.getParameter("catelog_id"); String
mingcheng=req.getParameter("mingcheng"); String
jieshao=req.getParameter("jieshao"); String fujian=req.getParameter("fujian");
int shichangjia=Integer.parseInt(req.getParameter("shichangjia")); int
tejia=Integer.parseInt(req.getParameter("shichangjia")); String del="no";
String sql="insert into
t_goods(id,fangyingshi,catelog_id,mingcheng,jieshao,fujian,shichangjia,tejia,del)
" + "values(?????????)"; Object[]
params={id,fangyingshi,catelog_id,mingcheng,jieshao,fujian,shichangjia,tejia,del};
DB mydb=new DB(); mydb.doPstm(sql, params); mydb.closed();
req.setAttribute("msg", " Operation successful "); String targetURL = "/common/msg.jsp";
dispatch(targetURL, req, res); } public void goodsMana(HttpServletRequest
req,HttpServletResponse res) throws ServletException, IOException { List
goodsList=new ArrayList(); String sql="select * from t_goods where del='no'
order by fangyingshi desc"; Object[] params={}; DB mydb=new DB(); try {
mydb.doPstm(sql, params); ResultSet rs=mydb.getRs(); while(rs.next()) { Tgoods
goods=new Tgoods(); goods.setId(rs.getString("id"));
goods.setFangyingshi(rs.getString("fangyingshi"));
goods.setCatelog_id(rs.getString("catelog_id"));
goods.setMingcheng(rs.getString("mingcheng"));
goods.setJieshao(rs.getString("jieshao"));
goods.setFujian(rs.getString("fujian"));
goods.setShichangjia(rs.getInt("shichangjia"));
goods.setTejia(rs.getInt("tejia")); goods.setDel(rs.getString("del"));
goodsList.add(goods); } rs.close(); } catch(Exception e) { e.printStackTrace();
} mydb.closed(); req.setAttribute("goodsList", goodsList);
req.getRequestDispatcher("admin/goods/goodsMana.jsp").forward(req, res); }
public void goodsDel(HttpServletRequest req,HttpServletResponse res) { String
id=req.getParameter("id"); String sql="update t_goods set del='yes' where
id="+id; Object[] params={}; DB mydb=new DB(); mydb.doPstm(sql, params);
mydb.closed(); req.setAttribute("msg", " Operation successful "); String targetURL =
"/common/msg.jsp"; dispatch(targetURL, req, res); } public void
goodsDetailHou(HttpServletRequest req,HttpServletResponse res) throws
ServletException, IOException { String id=req.getParameter("id");
req.setAttribute("goods", liuService.getGoods(id));
req.getRequestDispatcher("admin/goods/goodsDetailHou.jsp").forward(req, res); }
public void goodsAll(HttpServletRequest req,HttpServletResponse res) throws
ServletException, IOException { List goodsList=new ArrayList(); //String
sql="select * from t_goods where del='no' and fangyingshi >? order by
fangyingshi desc"; String sql="select * from t_goods where del='no' order by
fangyingshi desc"; Object[] params={new
SimpleDateFormat("yyyy-MM-dd").format(new Date())}; DB mydb=new DB(); try {
mydb.doPstm(sql, null); ResultSet rs=mydb.getRs(); while(rs.next()) { Tgoods
goods=new Tgoods(); goods.setId(rs.getString("id"));
goods.setFangyingshi(rs.getString("fangyingshi"));
goods.setCatelog_id(rs.getString("catelog_id"));
goods.setMingcheng(rs.getString("mingcheng"));
goods.setJieshao(rs.getString("jieshao"));
goods.setFujian(rs.getString("fujian"));
goods.setShichangjia(rs.getInt("shichangjia"));
goods.setTejia(rs.getInt("tejia")); goods.setDel(rs.getString("del"));
goodsList.add(goods); } rs.close(); } catch(Exception e) { e.printStackTrace();
} mydb.closed(); if(goodsList.size()>8) { goodsList=goodsList.subList(0, 8); }
req.setAttribute("goodsList", goodsList);
req.getRequestDispatcher("site/goods/goodsAll.jsp").forward(req, res); } public
void goodsByCatelog(HttpServletRequest req,HttpServletResponse res) throws
ServletException, IOException { String
catelog_id=req.getParameter("catelog_id"); req.setAttribute("goodsList",
liuService.goodsByCatelog(catelog_id));
req.getRequestDispatcher("site/goods/goodsByCatelog.jsp").forward(req, res); }
public void goodsDetailQian(HttpServletRequest req,HttpServletResponse res)
throws ServletException, IOException { String id=req.getParameter("id");
req.setAttribute("goods", liuService.getGoods(id));
req.getRequestDispatcher("site/goods/goodsDetailQian.jsp").forward(req, res); }
public void dispatch(String targetURI,HttpServletRequest
request,HttpServletResponse response) { RequestDispatcher dispatch =
getServletContext().getRequestDispatcher(targetURI); try {
dispatch.forward(request, response); return; } catch (ServletException e) {
e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public
void init(ServletConfig config) throws ServletException { super.init(config); }
public void destroy() { } }
Source code acquisition : My blog Homepage " resources " Download in !

Technology
©2019-2020 Toolsou All rights reserved,
Solve in servlet The Chinese output in is a question mark C String function and character function in language MySQL management 35 A small coup optimization Java performance —— Concise article Seven sorting algorithms (java code ) use Ansible Batch deployment SSH Password free login to remote host according to excel generate create Build table SQL sentence Spring Source code series ( sixteen )Spring merge BeanDefinition Principle of Virtual machine installation Linux course What are the common exception classes ?