基于javaweb+mysql的jsp+servlet火车票网上订票系统(前台、后台)(java+jsp+servlet+javabean+mysql+tomcat)

基于javaweb+mysql的jsp+servlet火车票网上订票系统(前台、后台)(java+jsp+servlet+javabean+mysql+tomcat)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

前台功能:用户查询车票信息、登录注册、购票、查看已购车票、修改密码等功能。

后台功能:管理员管理、用户管理、火车信息管理、站点信息管理、线路信息管理、车票信息管理、购票信息管理等。

后台:

前台

技术框架

JSP Servlet MySQL JDBC Tomcat CSS JavaScript

基于javaweb+mysql的JSP+Servlet火车票网上订票系统(前台、后台)(java+jsp+servlet+javabean+mysql+tomcat)

	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//设置传输数据编码方式
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		HttpSession session=request.getSession();
		//获取使用者信息
		Object userid=session.getAttribute("userid");
		Object utype=session.getAttribute("utype");
		//创建json对象
		JSONObject json=new JSONObject();
		String sql=request.getParameter("sql");
		if(userid==null||utype==null){
			json.put("msg", "请重新登陆");
		}else{
			HandleProperties hp=new HandleProperties(session,utype+""+userid);
			hp.setValue("sql", sql);
			json.put("msg", 1);
		}
		PrintWriter out=response.getWriter();
		out.print(json.toString());
		out.flush();
		out.close();
	}

	/**
	 * Initialization of the servlet. <br>

	/**
	 * Constructor of the object.
	 */
	public Add() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//设置传输数据编码方式
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		HttpSession session=request.getSession();
		//获取当前登录用户信息
		Object utype=session.getAttribute("utype");
		Object userid=session.getAttribute("userid");
		//创建json对象
			String cz=request.getParameter("cz");
			String znums=request.getParameter("znums");
			String xcnums=request.getParameter("xcnums");
			String traintype=request.getParameter("traintype");
			String ids=request.getParameter("idi");
			ResultSet rs=db.query("select id from traininfo where tname='"+tnames+"'");
			if(rs!=null){
				boolean bl=false;
				int id=-1;
				try {
					while(rs.next()){
						id=rs.getInt("id");
						if(!String.valueOf(id).equals(ids)){
							bl=true;
						}
					}
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				if(bl){
					json.put("msg", "车次已注册");
				}else{
					int bls=db.deleteOrUpdate("update traininfo set tname='"+tnames+"', cz='"+cz+"' ,traintype='"+traintype+"',znums="+znums+",xcnums="+xcnums+" where id="+ids);
					if(bls>0){
						json.put("msg", "修改成功。");
					}else{
						json.put("msg", "修改失败");
					}
				}
			}else{
				json.put("msg", "操作错误01");
			}
		}
		//站点信息修改
		if("zhandian".equals(tname)){
			String zdname=request.getParameter("zdname");
			String ids=request.getParameter("idi");
			ResultSet rs=db.query("select id from zhandian where zdname='"+zdname+"'");
			if(rs!=null){
				boolean bl=false;
				int id=-1;
				try {
					while(rs.next()){
						id=rs.getInt("id");
						if(!String.valueOf(id).equals(ids)){
							bl=true;
						}
					}
			if(rs!=null){
				boolean bl=false;
				int id=-1;
				try {
					while(rs.next()){
						id=rs.getInt("id");
						if(!String.valueOf(id).equals(ids)){
							bl=true;
						}
					}
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				if(bl){
					json.put("msg", "站点名称已存在");
				}else{
					int bls=db.deleteOrUpdate("update zhandian set zdname='"+zdname+"' where id="+ids);
					if(bls>0){
						json.put("msg", "修改成功。");
					}else{
						json.put("msg", "修改失败");
					}
				}
			}else{
				json.put("msg", "操作错误01");
			}
		}
		//车票信息修改
		if("piao".equals(tname)){
			String tid=request.getParameter("tid");
			String szdid=request.getParameter("szdid");
			String ezdid=request.getParameter("ezdid");
			String stime=request.getParameter("stime");
			String pval=request.getParameter("pval");
			String ptype=request.getParameter("ptype");
			String cxzh=request.getParameter("cxzh");
			String yxsj=request.getParameter("yxsj");
			String ids=request.getParameter("idi");
			int bls=db.deleteOrUpdate("update piao set yxsj='"+yxsj+"', cxzh='"+cxzh+"' ,ptype='"+ptype+"',pval="+pval+", stime='"+stime+"', tid="+tid+",szdid="+szdid+",ezdid="+ezdid+" where id="+ids);
			if(bls>0){
				json.put("msg", "修改成功。");
			}else{
				json.put("msg", "修改失败");
			}
		}
		PrintWriter out=response.getWriter();
				ResultSet rs2=db2.query("select zhandian.*,xh from xianlu,zhandian where xianlu.zdid=zhandian.id and xianlu.tid="+t.getId()+" order by xh");
				List<Zhandian> zdlist=FindService.getZhandian(rs2);
				xl.setZdlist(zdlist);
				xllist.add(xl);
			}
			request.setAttribute("alist", xllist);
			request.getRequestDispatcher("/admin/initxianlu.jsp").forward(request, response);
			return;
		}
		//线路信息管理初始化
		if("xianlu".equals(tname)){
			String ids=request.getParameter("tid");
			if("1".equals(flgs)){
				sql="select zhandian.*,xh from zhandian,xianlu where zhandian.id=xianlu.zdid and xianlu.tid="+ids+"  order by xh";
				hp.setValue("sql", sql);
			}else{
				sql=hp.readValue("sql");
			}
			ResultSet rs=db.query(sql);
			List<Zhandian> zlist=FindService.getZhandians(rs);
			request.setAttribute("alist", zlist);
			DbConn db2=new DbConn();
			ResultSet rs2=db2.query("select * from zhandian where id not in(select zdid from xianlu where tid="+ids+")");
			List<Zhandian> zdlist=FindService.getZhandian(rs2);
			request.setAttribute("zdlist", zdlist);
			DbConn db3=new DbConn();
			Object tn=db3.getOnlyOne("select tname from traininfo where id="+ids);
			Traininfo t=new Traininfo();
			t.setId(Integer.parseInt(ids));
			t.setTname(tn+"");
			request.setAttribute("t", t);
			request.getRequestDispatcher("/admin/mgxianlu.jsp").forward(request, response);
			return;
		}
		//车票信息管理初始化
		if("piao".equals(tname)){
			String ids=request.getParameter("tid");
			if("1".equals(flgs)){
				sql="select tmp.*,zdname as eaddr,tname,traintype from (select piao.*,zdname as saddr from piao,zhandian where piao.szdid=zhandian.id and yxsj='1975-01-01' and zdname like '%0%') tmp,zhandian,traininfo where tmp.tid=traininfo.id and tmp.ezdid=zhandian.id and zdname like '%0%' and 1=0";
				hp.setValue("sql", sql);
			}else{
				sql=hp.readValue("sql");
			}
			Object sql=session.getAttribute("sql");
			if(sql==null){
				
			}else{
				sqls=sql.toString();
			}
		}
		if(!"".equals(sqls)){
			DbConn db=new DbConn();
			ResultSet rs=db.query(sqls);
			List<Piao> alist=FindService.getPiao(rs);
			request.setAttribute("alist", alist);
		}
		request.getRequestDispatcher("/main.jsp").forward(request, response);
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
package dp.admin.svlt;

public class GetZdByTid extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public GetZdByTid() {
		super();
			String ptype=request.getParameter("ptype");
			String cxzh=request.getParameter("cxzh");
			String yxsj=request.getParameter("yxsj");
			boolean bl=db.insort("insert into piao(szdid,ezdid,tid,stime,pval,ptype,cxzh,yxsj) values("+szdid+","+ezdid+","+tid+",'"+stime+"',"+pval+",'"+ptype+"','"+cxzh+"','"+yxsj+"')");
			if(!bl){
				json.put("msg", "添加成功。");
			}else{
				json.put("msg", "添加失败");
			}
		}
		PrintWriter out=response.getWriter();
		out.print(json.toString());
		out.flush();
		out.close();
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
package dp.admin.svlt;

public class Del extends HttpServlet {

		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//设置传输数据编码方式
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		HttpSession session=request.getSession();
		//获取当前登录用户信息
		Object utype=session.getAttribute("utype");
		Object userid=session.getAttribute("userid");
		//创建json对象
		JSONObject json=new JSONObject();
		if(utype==null||userid==null){
}
package dp.svlt;

public class LoginSvlt extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public LoginSvlt() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
		// Put your code here
	}

}
package dp.admin.svlt;

public class CkSvlt extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public CkSvlt() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server

	/**
	 * 读取Properties综合类,默认绑定到temp下的.properties文件。
	 */
	public class HandleProperties {
	    //配置文件的路径
	    private String configPath=null;
	    
	    /**
	     * 配置文件对象
	     */
	    private Properties props=null;
	    
	    /**
	     * 默认构造函数,用于sh运行,自动找到temp下的.properties。
	     */
	    public HandleProperties(HttpSession session,String fname) throws IOException{
	    	String path=session.getServletContext().getRealPath("/");
			File f=new File(path+"prop/"+fname+".properties");
			if(!f.exists()){
				f.getParentFile().mkdirs();
			}
			if(!f.exists()){
				try {
					f.createNewFile();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			configPath=f.getPath();
	        FileInputStream in = new FileInputStream(f);
	        props = new Properties();
	        props.load(in);
	        //关闭资源
	        in.close();
	    }
	    
	    /**
	     * 根据key值读取配置的值
	     * @param key key值
			}else{
				json.put("msg", "操作错误01");
			}
		}
		//车票信息修改
		if("piao".equals(tname)){
			String tid=request.getParameter("tid");
			String szdid=request.getParameter("szdid");
			String ezdid=request.getParameter("ezdid");
			String stime=request.getParameter("stime");
			String pval=request.getParameter("pval");
			String ptype=request.getParameter("ptype");
			String cxzh=request.getParameter("cxzh");
			String yxsj=request.getParameter("yxsj");
			String ids=request.getParameter("idi");
			int bls=db.deleteOrUpdate("update piao set yxsj='"+yxsj+"', cxzh='"+cxzh+"' ,ptype='"+ptype+"',pval="+pval+", stime='"+stime+"', tid="+tid+",szdid="+szdid+",ezdid="+ezdid+" where id="+ids);
			if(bls>0){
				json.put("msg", "修改成功。");
			}else{
				json.put("msg", "修改失败");
			}
		}
		PrintWriter out=response.getWriter();
		out.print(json.toString());
		out.flush();
		out.close();
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
package dp.admin.svlt;

					json.put("msg", "添加失败");
				}
			}
		}
		//站点信息添加
		if("zhandian".equals(tname)){
			String zdname=request.getParameter("zdname");
			boolean bl=db.checkTrue("select id from zhandian where zdname='"+zdname+"'");
			if(bl){
				json.put("msg", "站点名称已存在");
			}else{
				bl=db.insort("insert into zhandian(zdname) values('"+zdname+"')");
				if(!bl){
					json.put("msg", "添加成功。");
				}else{
					json.put("msg", "添加失败");
				}
			}
		}
		//线路信息添加
		if("xianlu".equals(tname)){
			String tid=request.getParameter("tid");
			String zdid=request.getParameter("zdid");
			String xh=request.getParameter("xh");
			DbConn db2=new DbConn();
			if(db.checkTrue("select id from xianlu where tid="+tid+"  and zdid="+zdid)){
				json.put("msg", "该线路已有该站点");
			}else if(db2.checkTrue("select id from xianlu where tid="+tid+" and xh="+xh)){
				json.put("msg", "站点序号已存在");
			}else{
				boolean bl=db.insort("insert into xianlu(xh,tid,zdid) values("+xh+","+tid+","+zdid+")");
				if(!bl){
					json.put("msg", "添加成功。");
				}else{
					json.put("msg", "添加失败");
				}
			}
		}
		//车票信息添加
		//data:{tname:'piao',"szdid":szdid,"stime":stime,"ezdid":ezdid,"pval":pval,"ptype":ptype,
		//"cxzh":cxzh,"yxsj":yxsj,"tid":tid,idi:ids},
		if("piao".equals(tname)){
			String tid=request.getParameter("tid");
			String szdid=request.getParameter("szdid");
			String ezdid=request.getParameter("ezdid");
			String stime=request.getParameter("stime");
			String pval=request.getParameter("pval");
			String ptype=request.getParameter("ptype");
			}else if(db.checkTrue("select id from xianlu where tid="+ids)){
				json.put("msg", "该火车有线路信息存在不能删除.");
			}else{
				int bls=db.deleteOrUpdate("delete from traininfo where id="+ids);
				if(bls>0){
					json.put("msg", 1);
				}else{
					json.put("msg", "删除失败");
				}
			}
		}
		//站点信息删除
		if("zhandian".equals(tname)){
			String ids=request.getParameter("idi");
			if(db.checkTrue("select id from xianlu where zdid="+ids)){
				json.put("msg", "该站点有线路信息存在不能删除.");
			}else{
				int bls=db.deleteOrUpdate("delete from zhandian where id="+ids);
				if(bls>0){
					json.put("msg", 1);
				}else{
					json.put("msg", "删除失败");
				}
			}
		}
		//线路信息删除
		if("xianlu".equals(tname)){
			String zdid=request.getParameter("zdid");
			String tid=request.getParameter("tid");
			int bls=db.deleteOrUpdate("delete from xianlu where zdid="+zdid+" and tid="+tid);
			if(bls>0){
				json.put("msg", 1);
			}else{
				json.put("msg", "删除失败");
			}
		}
		//车票信息删除
		if("piao".equals(tname)){
			String id=request.getParameter("idi");
			int bls=db.deleteOrUpdate("delete from piao where id="+id);
			if(bls>0){
				json.put("msg", 1);
		response.setContentType("text/html");
		String tid=request.getParameter("tid");
		JSONObject json=new JSONObject();
		if(!"".equals(tid)&&tid!=null){
			DbConn db=new DbConn();
			ResultSet rs=db.query("select zhandian.* from xianlu,zhandian where xianlu.zdid=zhandian.id and xianlu.tid="+tid);
			List<Zhandian> zdlist=FindService.getZhandian(rs);
			json.put("msg", 1);
			json.put("zdlist", zdlist);
		}else{
			json.put("msg", 0);
		}
		PrintWriter out=response.getWriter();
		out.print(json.toString());
		out.flush();
		out.close();
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
package dp.admin.svlt;

public class CkSvlt extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public CkSvlt() {
		super();
	}

	/**

	/**
	 * 读取Properties综合类,默认绑定到temp下的.properties文件。
	 */
	public class HandleProperties {
	    //配置文件的路径
	    private String configPath=null;
	    
	    /**
	     * 配置文件对象
	     */
	    private Properties props=null;
	    
	    /**
	     * 默认构造函数,用于sh运行,自动找到temp下的.properties。
	     */
	    public HandleProperties(HttpSession session,String fname) throws IOException{
	    	String path=session.getServletContext().getRealPath("/");
			File f=new File(path+"prop/"+fname+".properties");
			if(!f.exists()){
				f.getParentFile().mkdirs();
			}
			if(!f.exists()){
				try {
					f.createNewFile();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			configPath=f.getPath();
	        FileInputStream in = new FileInputStream(f);
	        props = new Properties();
	        props.load(in);
	        //关闭资源
	        in.close();
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html");
		//设置传输数据编码方式
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		HttpSession session=request.getSession();
		Object utype=session.getAttribute("utype");
		Object userid=session.getAttribute("userid");
		JSONObject json=new JSONObject();
		if(utype==null||userid==null){
			json.put("msg", "请重新登陆");
		}else{
			String opwd=request.getParameter("opwd");
			String npwd=request.getParameter("npwd");
			DbConn db=new DbConn();
			String sql="";
			if("gly".equals(utype.toString())){
				sql="select id from userinfo where id="+userid+" and upassword='"+opwd+"'";
			}else if("cus".equals(utype.toString())){
				sql="select id from cusinfo where id="+userid+" and cpassword='"+opwd+"'";
			}
			boolean bl=false;
			if("".equals(sql)){
				json.put("msg", "系统错误01");
			}else{
				bl=db.checkTrue(sql);
			}
			if(bl){
				if("gly".equals(utype.toString())){
					sql="update userinfo set upassword='"+npwd+"' where id="+userid;
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//设置传输数据编码方式
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		HttpSession session=request.getSession();
		//获取当前登录用户信息
		Object utype=session.getAttribute("utype");
		Object userid=session.getAttribute("userid");
		//创建json对象
		JSONObject json=new JSONObject();
		if(utype==null||userid==null){
			json.put("msg", "请重新登陆。");
			return;
		}
		//获取前台数据tname
		String tname=request.getParameter("tname");
		//创建数据库操作对象
		DbConn db=new DbConn();
		//管理员信息修改
		if("admin".equals(tname)){
			String un=request.getParameter("uname");
			String up=request.getParameter("upassword");
			String ids=request.getParameter("idi");
			ResultSet rs=db.query("select id from userinfo where uname='"+un+"'");
			if(rs!=null){
				boolean bl=false;
				int id=-1;
				try {
					while(rs.next()){
						id=rs.getInt("id");
						if(!String.valueOf(id).equals(ids)){
							bl=true;
						}
					}
				} catch (SQLException e) {
					// TODO Auto-generated catch block
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {	
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		String rgidcard=request.getParameter("rgidcard");
		String rgpassword=request.getParameter("rgpassword");
		String rgsname=request.getParameter("rgsname");
		JSONObject json =new JSONObject();
		DbConn db=new DbConn();
		if(userid==null||utype==null){
			json.put("msg", "请重新登陆");
		}else{
			HandleProperties hp=new HandleProperties(session,utype+""+userid);
			hp.setValue("sql", sql);
			json.put("msg", 1);
		}
		PrintWriter out=response.getWriter();
		out.print(json.toString());
		out.flush();
		out.close();
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
package dp.svlt;

public class LogoutSvlt extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public LogoutSvlt() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html");
		//设置传输数据编码方式
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		//获取前台传送的变量,账号,密码和用户类型
		String uname=request.getParameter("uname");
		String upassword=request.getParameter("upassword");
		String utype=request.getParameter("utype");
		//创建数据库操作对象
		DbConn db=new DbConn();
		//sql语句变量定义
		String sql="";
		int id=-1;
		String usname="";
		if("gly".equals(utype)){
			sql="select id from userinfo where uname='"+uname+"' and upassword='"+upassword+"'";
		}else if("cus".equals(utype)){
			sql="select id,cname from cusinfo where cidcard='"+uname+"' and cpassword='"+upassword+"'";
		}
		JSONObject json=new JSONObject();
		if("".equals(sql)){
			json.put("msg", "系统错误01.");
		}else{
			ResultSet rs=db.query(sql);
			if(rs==null){
				json.put("msg", "系统错误02");
			}else{
				try {
					while(rs.next()){
		// Put your code here
	}

}
package dp.svlt;

public class LoginSvlt extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public LoginSvlt() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	public GetZdByTid() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//设置传输数据编码方式
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		String tid=request.getParameter("tid");
		JSONObject json=new JSONObject();
		if(!"".equals(tid)&&tid!=null){
			DbConn db=new DbConn();
			ResultSet rs=db.query("select zhandian.* from xianlu,zhandian where xianlu.zdid=zhandian.id and xianlu.tid="+tid);
			List<Zhandian> zdlist=FindService.getZhandian(rs);

public class UpdSvlt extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public UpdSvlt() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//设置传输数据编码方式
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
package dp.admin.svlt;

public class Del extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public Del() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {	
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		String rgidcard=request.getParameter("rgidcard");
		String rgpassword=request.getParameter("rgpassword");
		String rgsname=request.getParameter("rgsname");
		JSONObject json =new JSONObject();
		DbConn db=new DbConn();
			if(db.checkTrue("select id from cusinfo where cidcard='"+rgidcard+"'")){
				json.put("msg", "身份证已注册");
			}else{
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
				boolean bl=db.insort("insert into cusinfo(cname,cidcard,cpassword,intime) values('"+rgsname+"','"+rgidcard+"','"+rgpassword+"','"+sdf.format(new Date())+"')");
				if(!bl){
					json.put("msg", "注册成功");
				}else{
					json.put("msg", "error:02");
				}
			}
		}else{
			json.put("msg", "error:01");
		}
		PrintWriter out = response.getWriter();
		out.print(json.toString());
		out.flush();
		out.close();
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
package dp.svlt;

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

管理员模块已更新 使用说明 1 电脑上装JDK 2 电脑上装mysql数据库 3 在dos下打开mysql后,把mysql.txt里的代码(包括insert代码)复制到dos下运行,记得最后再按一下回车键,让最后一行也运行。 4 在eclipse或myeclipse下新建java项目(注意不是jsp项目)后,复制src文件夹到替换项目里的src。然后在复制train.pro,右击项目名粘贴(即把train.pro 加到项目 目录里) 5 把mysql-connector-java-5.1.13-bin.jar 添加到项目里。右键项目,点击Build Path 后再点击add External Archives 后找到mysql-connector-java-5.1.13-bin.jar文件打开即可。 6 在eclipse里打开wed包下MySqlH.java 设置mysql root用户的密码,String password="mysql"; 我的密码是mysql,这里改成你自己的密码。 7 运行client包下的Administrator.java ,若没有错如则OK。 8 运行后点击工具条里的‘工具’,后再点击‘生成所有列车表’,若成功,此时可看见列车表里增加了很多数据。可能有点慢,稍等一会。 9 若8 成功,则点击工具条里的‘工具’,后再点击‘生成所有车票表’,若成功,此时可看见车票表里增加了很多数据。可能有点慢,稍等一会。 关于工具条理的‘生成所有列车表’ ‘生成所有车票表’ "生成列车表" "生成车票表" "设置天数" 的介绍 1 ‘生成所有列车表’ 是根据车次表和车站表的全部数据自动生成 列车表 里的数据, 仅限于第一次时使用。 2 ‘生成所有车票表’ 是根据 列车表 里的全部数据自动生成 车票表 里的数据, 仅限于第一次时使用。 3 "生成列车表" 是根据你输入的某一列车次(必须是车次表里的车次和车站表里有与之相关的数据时才能使用)自动生成 列车表 里的数据 4 "生成车票表" 是根据你输入的某一ID(必须是列车表里的ID)自动生成 车票表 里的数据 5 "设置天数" 是设置能够预订和销售的最多天数,默认是3 天,即能预订和销售3天内的车票 注意: 1 订票记录表,销售记录表,退票记录表里的时间是系统自动生成,在任何情况下都不需填写 也不能修改 2 在管理员模块里添加,删除和修改后需更新一下才能显示,只需点一下别的表,在点刚修改的表即可,数据完全正确 3 退票员和销售员登录时分别查询对应表的记录,因此需要在管理员模块里增加相应记录后才能登录 4 此系统暂时已知还有多个缺陷,如如退票是可一张票可退多次,一个订票id可买多张车票。由于时间因素,就不在修补了。 5 train.pro 是个配置文件,可用记事本打开,尽量在train下的Main_Config.java里修改其配置信息
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值