基于javaweb+mysql的jsp+servlet航班机票预订管理系统(java+servlet+jsp+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的JSP+Servlet航班机票预订管理系统(java+servlet+jsp+mysql)
首页:
http://localhost:8080/welcome.html
用户:
机票查询、选座购买、查询已购票、退票等
管理员(admin/123456):
查询售票统计报表
int pagesize = Integer.parseInt(request.getParameter("thepagesize"));
int whichpage = Integer.parseInt(request.getParameter("whichpage"));
String startcity = request.getParameter("startcity");
String endcity = request.getParameter("endcity");
String startdate=request.getParameter("startdate") ;
Queryservice qs = new Queryservice();
List<planetime> list = qs.select(startcity, endcity, startdate, pagesize, whichpage);
request.setAttribute("alist", list);
request.setAttribute("sc", startcity);
request.setAttribute("ec", endcity);
request.setAttribute("sd", startdate);
request.setAttribute("wp",whichpage);
request.getRequestDispatcher("information.jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
/**
* Servlet implementation class Buy
*/
/**
* @see HttpServlet#HttpServlet()
*/
public writedown() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
String personidnumber = request.getParameter("idnumber");
String flight = request.getParameter("filght");
String theseat = request.getParameter("seats");
String moneys = request.getParameter("moneys");
String seatnumber = request.getParameter("seatnumber");
Recordservice rs = new Recordservice();
rs.recordInformation(personidnumber, flight, theseat, moneys);
rs.changetheplanetime(flight, seatnumber, moneys, theseat);
request.getRequestDispatcher("information.jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
/**
* Servlet implementation class Verify
*/
public class Verify extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Verify() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
String username = request.getParameter("username");
String password = request.getParameter("password");
Queryservice qs = new Queryservice();
int isright = qs.isRight(username, password);
PrintWriter out = response.getWriter();
out.print(isright);
out.flush();
out.close();
String password = request.getParameter("password");
Queryservice qs = new Queryservice();
int isright = qs.isRight(username, password);
PrintWriter out = response.getWriter();
out.print(isright);
out.flush();
out.close();
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
/**
* Servlet implementation class recordRefund
*/
public class recordRefund extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public recordRefund() {
super();
// TODO Auto-generated constructor stub
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
String theflightcode=request.getParameter("theflightcode");
String thestartdate=request.getParameter("thestartdate");
Buyservice b = new Buyservice();
ArrayList<planetime> planetimealist = new ArrayList<planetime>();
planetimealist = b.buyselect(theflightcode);
float discount = b.getthediscount(theflightcode, thestartdate);
ArrayList<ArrayList<Integer>> alali = new ArrayList<ArrayList<Integer>>();
alali = b.gettheseat(theflightcode);
request.setAttribute("thediscocunt",discount);
request.setAttribute("theplanetimealist",planetimealist);
request.setAttribute("alal",alali);
request.getRequestDispatcher("buy.jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
/**
* Servlet implementation class Jumptouser
*/
public class Jumptouser extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Statistics() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
int pagesize = Integer.parseInt(request.getParameter("thepagesize"));
int whichpage = Integer.parseInt(request.getParameter("whichpage"));
Queryservice qs = new Queryservice();
List<planetime> list = qs.selectall(pagesize, whichpage);
request.setAttribute("alist", list);
request.setAttribute("wp",whichpage);
request.getRequestDispatcher("sum.jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
}else if(whichkindofseats==2){
whichkindofseat="b";
}else{
whichkindofseat="c";
}
float takemoney = Float.parseFloat(request.getParameter("seatype"));
request.setAttribute("themoney", takemoney);
request.setAttribute("theflightcode", theflightcode);
request.setAttribute("whichkindofseat", whichkindofseat);
request.setAttribute("whichseat", whichseat);
request.getRequestDispatcher("pay.jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
/**
* Servlet implementation class getUserticket
*/
public class getUserticket extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public getUserticket() {
super();
out.print(isright);
out.flush();
out.close();
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
/**
* Servlet implementation class recordRefund
*/
public class recordRefund extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public recordRefund() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Query() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
int pagesize = Integer.parseInt(request.getParameter("thepagesize"));
int whichpage = Integer.parseInt(request.getParameter("whichpage"));
String startcity = request.getParameter("startcity");
String endcity = request.getParameter("endcity");
String startdate=request.getParameter("startdate") ;
Queryservice qs = new Queryservice();
List<planetime> list = qs.select(startcity, endcity, startdate, pagesize, whichpage);
request.setAttribute("alist", list);
request.setAttribute("sc", startcity);
request.setAttribute("ec", endcity);
request.setAttribute("sd", startdate);
request.setAttribute("wp",whichpage);
request.getRequestDispatcher("information.jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
/**
* Servlet implementation class getUserticket
*/
public class getUserticket extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public getUserticket() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
int pagesize = Integer.parseInt(request.getParameter("thepagesize"));
int whichpage = Integer.parseInt(request.getParameter("whichpage"));
String idnumber = request.getParameter("theidnumber");
/**
* Servlet implementation class Statistics
*/
public class Statistics extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Statistics() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
int pagesize = Integer.parseInt(request.getParameter("thepagesize"));
int whichpage = Integer.parseInt(request.getParameter("whichpage"));
Queryservice qs = new Queryservice();
List<planetime> list = qs.selectall(pagesize, whichpage);
request.setAttribute("alist", list);
request.setAttribute("wp",whichpage);
request.getRequestDispatcher("sum.jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
/**
* Servlet implementation class getUserticket
*/
public class getUserticket extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public getUserticket() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
int pagesize = Integer.parseInt(request.getParameter("thepagesize"));
int whichpage = Integer.parseInt(request.getParameter("whichpage"));
String idnumber = request.getParameter("theidnumber");
Queryservice qs = new Queryservice();
ArrayList<saledticket> list = qs.selectsaledticket(idnumber, pagesize, whichpage);
request.setAttribute("alist", list);
request.setAttribute("in", idnumber);
request.setAttribute("wp",whichpage);
request.getRequestDispatcher("refund.jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
/**
* Servlet implementation class writedown
*/
int pagesize = Integer.parseInt(request.getParameter("thepagesize"));
int whichpage = Integer.parseInt(request.getParameter("whichpage"));
Queryservice qs = new Queryservice();
List<planetime> list = qs.selectall(pagesize, whichpage);
request.setAttribute("alist", list);
request.setAttribute("wp",whichpage);
request.getRequestDispatcher("sum.jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
/**
* Servlet implementation class Verify
*/
public class Verify extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Verify() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
String theflightcode = request.getParameter("theflightcodes");
String whichseat = request.getParameter("sit");
String tempname = "n"+whichseat;
int whichkindofseats = Integer.parseInt(request.getParameter(tempname));
String whichkindofseat;
if(whichkindofseats==1){
whichkindofseat="a";
}else if(whichkindofseats==2){
whichkindofseat="b";
}else{
whichkindofseat="c";
}
float takemoney = Float.parseFloat(request.getParameter("seatype"));
request.setAttribute("themoney", takemoney);
request.setAttribute("theflightcode", theflightcode);
request.setAttribute("whichkindofseat", whichkindofseat);
request.setAttribute("whichseat", whichseat);
request.getRequestDispatcher("pay.jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
/**
* Servlet implementation class Query
*/
public class Query extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Query() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
int pagesize = Integer.parseInt(request.getParameter("thepagesize"));
int whichpage = Integer.parseInt(request.getParameter("whichpage"));
String startcity = request.getParameter("startcity");
String endcity = request.getParameter("endcity");
String startdate=request.getParameter("startdate") ;
Queryservice qs = new Queryservice();
List<planetime> list = qs.select(startcity, endcity, startdate, pagesize, whichpage);
request.setAttribute("alist", list);
request.setAttribute("sc", startcity);
request.setAttribute("ec", endcity);
request.setAttribute("sd", startdate);
request.setAttribute("wp",whichpage);
request.getRequestDispatcher("information.jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
/**
* Servlet implementation class getUserticket
*/
public class getUserticket extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public getUserticket() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
int pagesize = Integer.parseInt(request.getParameter("thepagesize"));
int whichpage = Integer.parseInt(request.getParameter("whichpage"));
String idnumber = request.getParameter("theidnumber");
Queryservice qs = new Queryservice();
ArrayList<saledticket> list = qs.selectsaledticket(idnumber, pagesize, whichpage);
request.setAttribute("alist", list);
request.setAttribute("in", idnumber);
request.setAttribute("wp",whichpage);
request.getRequestDispatcher("refund.jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
String theflightcode=request.getParameter("theflightcode");
String thestartdate=request.getParameter("thestartdate");
Buyservice b = new Buyservice();
ArrayList<planetime> planetimealist = new ArrayList<planetime>();
planetimealist = b.buyselect(theflightcode);
float discount = b.getthediscount(theflightcode, thestartdate);
ArrayList<ArrayList<Integer>> alali = new ArrayList<ArrayList<Integer>>();
alali = b.gettheseat(theflightcode);
request.setAttribute("thediscocunt",discount);
request.setAttribute("theplanetimealist",planetimealist);
request.setAttribute("alal",alali);
request.getRequestDispatcher("buy.jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
/**
* Servlet implementation class Jumptouser
*/
public class Jumptouser extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Jumptouser() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
/**
* Servlet implementation class getUserticket
*/
public class getUserticket extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public getUserticket() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
int pagesize = Integer.parseInt(request.getParameter("thepagesize"));
int whichpage = Integer.parseInt(request.getParameter("whichpage"));
String idnumber = request.getParameter("theidnumber");
Queryservice qs = new Queryservice();
ArrayList<saledticket> list = qs.selectsaledticket(idnumber, pagesize, whichpage);
request.setAttribute("alist", list);
request.setAttribute("in", idnumber);
request.setAttribute("wp",whichpage);
request.getRequestDispatcher("refund.jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub