基于javaweb+mysql的jsp+servlet网上订餐在线点餐管理系统(前台、后台)(java+jsp+servlet+jdbc+mysql+tomcat)

基于javaweb+mysql的jsp+servlet网上订餐在线点餐管理系统(前台、后台)(java+jsp+servlet+jdbc+mysql+tomcat)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

1.前台模块:

	(1)食品展示模块

	(2)食品查询模块

	(3)购物车模块

	(4)收银台模块

	(5)用户维护模块

	(6)订单查询模块

	(7)公告模块

	 

2.后台模块:

	(1)食品管理模块

	(2)用户管理模块

	(3)管理员维护模块

	(4)订单管理模块

	(5)公告管理模块

	(6)留言管理模块

eclipse或MyEclipse或idea

普通用户(前台)

管理员(后台)

技术框架

CSS JavaScript JSP Servlet JDBC MySQL

基于javaweb+mysql的JSP+Servlet网上订餐在线点餐管理系统(前台、后台)(java+jsp+servlet+jdbc+mysql+tomcat)

	}

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

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Validate vd = new Validate();
		String userid = vd.getUnicode(request.getParameter("userid"));
		String bookname = vd.getUnicode(request.getParameter("bookname"));
		String orderda = vd.getUnicode(request.getParameter("orderda"));
		String orderxiao = vd.getUnicode(request.getParameter("orderxiao"));
		String sql = "select a.id as userid,b.id as bookid,c.id as orderid,realname,phone,address,b.name as bookname,booksum,price1,times from users a,books b,orders c where a.id=c.userid and b.id=c.bookid ";
		String[] args = {"userid","bookid","orderid","realname","phone","address","bookname","booksum","price1","times"};
		if(userid != null && !userid.equals("")){
			sql += "and a.id='"+userid+"'";
		}
		if(bookname != null && !bookname.equals("")){
			sql += "and b.name like '%"+bookname+"%'";
		}
		if(orderda != null && !orderda.equals("")){
			sql += "and c.booksum>"+orderda;
		}
		if(orderxiao != null && !orderxiao.equals("")){
			sql += "and c.booksum<"+orderxiao;
		}
		SelectBean sb = new SelectBean();
		ArrayList al = sb.select(sql, args);
		request.setAttribute("order", al);
		RequestDispatcher rd=request.getRequestDispatcher("/admin/order2.jsp");
        rd.forward(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request,response);
	}

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

public class UpdateBookServlet extends HttpServlet {

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

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

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Validate vd = new Validate();
		String id = vd.getUnicode(request.getParameter("id"));
		String name = vd.getUnicode(request.getParameter("name"));
		String author = vd.getUnicode(request.getParameter("author"));
		String price1 = vd.getUnicode(request.getParameter("price1"));
		String brief = vd.getUnicode(request.getParameter("brief"));
		String type = vd.getUnicode(request.getParameter("type"));
		String sql ="update books set name='"+name+"',author='"+author+"',brief='"+brief+"',type='"+type+"',price1='"+price1+"' where id='"+id+"'";
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		ib.insertANDupdateANDdel(sql);
		SelectBean sb = new SelectBean();
		String sql2 = "select * from books where id='"+id+"'";
		String[] args2 = {"id","name","author","publishing","number","price","storage","brief","type","tate","sums","imgpath","price1","sums1"};
		ArrayList al2 = sb.select(sql2, args2);
		request.setAttribute("bookinf", al2);
		request.setAttribute("ok", "1");

		RequestDispatcher rd=request.getRequestDispatcher("/admin/updatebook.jsp");
        rd.forward(request,response);
        //String s1 = "";
        if(s != null)
        {
            String s2 = "";
            for(int i = 0;i < s.length();i++)
            {
                if(s.charAt(i) == ',')
                {
                    if(!m_deniedFilesList.contains(s2))
                    {
                        m_deniedFilesList.addElement(s2);
                    }
                    s2 = "";
                }
                else
                {
                    s2 = s2 + s.charAt(i);
                }
            }

            //if(s2 != "")
            if(!s2.equals(""))
            {
                m_deniedFilesList.addElement(s2);
            }
        }
        else
        {
            m_deniedFilesList = null;
        }
    }

    public void setAllowedFilesList(String s)
    {
        //String s1 = "";
        if(s != null)
        {
            String s2 = "";
            for(int i = 0;i < s.length();i++)
            {
                if(s.charAt(i) == ',')
                {
                    if(!m_allowedFilesList.contains(s2))
                    {
                        m_allowedFilesList.addElement(s2);
                    }
                    s2 = "";
                }
                else
                {
                    s2 = s2 + s.charAt(i);
		doGet(request, response);
	}

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

}

public class AddBookServlet extends HttpServlet {

	private ServletConfig config;
	/**
	 * Constructor of the object.
	 */
	public AddBookServlet() {
		super();
	}

	final public void init(ServletConfig config) throws ServletException
	{
		this.config = config;
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		

		SelectBean ib = new SelectBean();
		
		String sql1 = "select * from types";
		String[] args1 = {"id","name"};
		ArrayList al1 = ib.select(sql1, args1);
		request.setAttribute("type", al1);
		
		String sql2 = "select * from books";
		String[] args2 = {"id","name","author","publishing","number","price","storage","brief","type","tate","sums","imgpath","price1","sums1"};
		ArrayList al2 = ib.select(sql2, args2);
		request.setAttribute("books", al2);
		
		String sql3 = "select * from books order by sums1 desc";
		String[] args3 = {"id","name","author","publishing","number","price","storage","brief","type","tate","sums","imgpath","price1","sums1"};
		ArrayList al3 = ib.select(sql3, args3);
		request.setAttribute("xiaosou", al3);
		
		String sql5 = "select * from books where tate=1";
		String[] args5 = {"id","name","author","publishing","number","price","storage","brief","type","tate","sums","imgpath","price1","sums1"};
		ArrayList al5 = ib.select(sql5, args5);
		request.setAttribute("tuibook", al5);
		
		String sql6 = "select * from books where tate=2";
		String[] args6 = {"id","name","author","publishing","number","price","storage","brief","type","tate","sums","imgpath","price1","sums1"};
		ArrayList al6 = ib.select(sql6, args6);
		request.setAttribute("newbook", al6);
		
		String sql7 = "select * from users";
		String[] args7 = {"id","name","pwd","realname","sex","age","card","address","phone","email","code"};
		ArrayList al7 = ib.select(sql7, args7);
		request.setAttribute("users", al7);
		
		String sql10 = "select * from leaveword";
		String[] args10 = {"id","users","title","content","times"};
		ArrayList al10 = ib.select(sql10, args10);
        m_response.setContentLength(abyte0.length);
        if(s2 == null)
        {
            m_response.setHeader("Content-Disposition","attachment;");
        }
        else
        {
            if(s2.length() == 0)
            {
                m_response.setHeader("Content-Disposition","attachment;");
            }
            else
            {
                m_response.setHeader("Content-Disposition","attachment; filename=" + s2);
            }
        }
        m_response.getOutputStream().write(abyte0,0,abyte0.length);
    }

    public void fieldToFile(ResultSet resultset,String s,String s1) throws ServletException,IOException,SmartUploadException,SQLException
    {
        try
        {
            if(m_application.getRealPath(s1) != null)
            {
                s1 = m_application.getRealPath(s1);
            }
            InputStream inputstream = resultset.getBinaryStream(s);
            FileOutputStream fileoutputstream = new FileOutputStream(s1);
            int i;
            while((i = inputstream.read()) != -1)
            {
                fileoutputstream.write(i);
            }
            fileoutputstream.close();
        }
        catch(Exception exception)
        {
            throw new SmartUploadException("Unable to save file from the DataBase (1020).");
        }
    }

    private String getDataFieldValue(String s,String s1)
    {
        String s2 = ""; // = new String();
        String s3 = ""; // = new String();
        int i = 0;
        //boolean flag = false;
        //boolean flag1 = false;
        //boolean flag2 = false;
        s2 = s1 + "=" + '"';
	/**
	 * Constructor of the object.
	 */
	public UpdateBookServlet() {
		super();
	}

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

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Validate vd = new Validate();
		String id = vd.getUnicode(request.getParameter("id"));
		String name = vd.getUnicode(request.getParameter("name"));
		String author = vd.getUnicode(request.getParameter("author"));
		String price1 = vd.getUnicode(request.getParameter("price1"));
		String brief = vd.getUnicode(request.getParameter("brief"));
		String type = vd.getUnicode(request.getParameter("type"));
		String sql ="update books set name='"+name+"',author='"+author+"',brief='"+brief+"',type='"+type+"',price1='"+price1+"' where id='"+id+"'";
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		ib.insertANDupdateANDdel(sql);
		SelectBean sb = new SelectBean();
		String sql2 = "select * from books where id='"+id+"'";
		String[] args2 = {"id","name","author","publishing","number","price","storage","brief","type","tate","sums","imgpath","price1","sums1"};
		ArrayList al2 = sb.select(sql2, args2);
		request.setAttribute("bookinf", al2);
		request.setAttribute("ok", "1");

		RequestDispatcher rd=request.getRequestDispatcher("/admin/updatebook.jsp");
        rd.forward(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request,response);
	}

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

}
                        m_allowedFilesList.addElement(s2);
                    }
                    s2 = "";
                }
                else
                {
                    s2 = s2 + s.charAt(i);
                }
            }
            //if(s2 != "")
            if(!s2.equals(""))
            {
                m_allowedFilesList.addElement(s2);
            }
        }
        else
        {
            m_allowedFilesList = null;
        }
    }

    public void setDenyPhysicalPath(boolean flag)
    {
        m_denyPhysicalPath = flag;
    }

    public void setForcePhysicalPath(boolean flag)
    {
        //m_forcePhysicalPath = flag;
    }

    public void setContentDisposition(String s)
    {
        m_contentDisposition = s;
    }

    public void setTotalMaxFileSize(long l)
    {
        m_totalMaxFileSize = l;
    }

    public void setMaxFileSize(long l)
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}

public class LeaveWordServlet extends HttpServlet {

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

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

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Validate vd = new Validate();
		String title = vd.getUnicode(request.getParameter("title"));
        {
            int j = s.length();
            s2 = s.substring(i,j);
        }
        return s2;
    }

    private String getTypeMIME(String s)
    {
        //String s1 = new String();
        int i = 0;
        i = s.indexOf("/");
        if(i != -1)
        {
            return s.substring(1,i);
        }
        else
        {
            return s;
        }
    }

    private String getSubTypeMIME(String s)
    {
        //String s1 = new String();
        //boolean flag = false;
        int i = 0;
        i = s.indexOf("/") + 1;
        if(i != -1)
        {
            int j = s.length();
            return s.substring(i,j);
        }
        else
        {
            return s;
        }
    }

    private String getContentDisp(String s)
    {
        m_currentIndex = 0;
        m_startData = 0;
        m_endData = 0;
        m_boundary = ""; //new String();
        m_totalMaxFileSize = 0L;
        m_maxFileSize = 0L;
        m_deniedFilesList = new Vector();
        m_allowedFilesList = new Vector();
        m_denyPhysicalPath = false;
        //m_forcePhysicalPath = false;
        m_contentDisposition = ""; //new String();
        m_files = new SmartFiles();
        m_formRequest = new SmartRequest();
    }

    /**
     * @deprecated Method init is deprecated
     */
    public final void init(ServletConfig servletconfig) throws ServletException
    {
        m_application = servletconfig.getServletContext();
    }

    /**
     * @deprecated Method service is deprecated
     */
    public void service(HttpServletRequest httpservletrequest,HttpServletResponse httpservletresponse) throws ServletException,IOException
    {
        m_request = httpservletrequest;
        m_response = httpservletresponse;
    }

    public final void initialize(ServletConfig servletconfig,HttpServletRequest httpservletrequest,HttpServletResponse httpservletresponse) throws ServletException
    {
        m_application = servletconfig.getServletContext();
        m_request = httpservletrequest;
        m_response = httpservletresponse;
    }

    public final void initialize(PageContext pagecontext) throws ServletException
    {
        m_application = pagecontext.getServletContext();

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Validate vd = new Validate();
		String username = vd.getUnicode(request.getParameter("username"));
		String bookname = vd.getUnicode(request.getParameter("bookname"));
		String sql = "select a.name as username,realname,b.name as bookname,c.* from users a,books b,loanbook c where a.id=c.users and b.id=c.books ";
		String[] args = {"username","realname","bookname","id","users","books","price","sumday","begintime","endtime","continueday","continuetime","flag"};
		
		if(username != null && !username.equals("")){
			sql += "and a.name like '%"+username+"%'";
		}
		if(bookname != null && !bookname.equals("")){
			sql += "and b.name like '%"+bookname+"%'";
		}
		
		SelectBean sb = new SelectBean();
		ArrayList al = sb.select(sql, args);
		request.setAttribute("order", al);
		RequestDispatcher rd=request.getRequestDispatcher("/admin/order.jsp");
        rd.forward(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request,response);
	}

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

}

    /**
     * @deprecated Method initialize is deprecated
     */
    public final void initialize(ServletContext servletcontext,HttpSession httpsession,HttpServletRequest httpservletrequest,HttpServletResponse httpservletresponse,JspWriter jspwriter) throws ServletException
    {
        m_application = servletcontext;
        m_request = httpservletrequest;
        m_response = httpservletresponse;
    }

    public void upload() throws ServletException,IOException,SmartUploadException
    {
        int i = 0;
        //boolean flag = false;
        boolean flag1 = false;
        //boolean flag2 = false;
        long l = 0L;
        //String s = "";//new String();
        //String s2 = "";//new String();
        String s4 = ""; //new String();
        String s5 = ""; //new String();
        String s6 = ""; //new String();
        String s7 = ""; //new String();
        String s8 = ""; //new String();
        String s9 = ""; //new String();
        String s10 = ""; //new String();
        m_totalBytes = m_request.getContentLength();
        m_binArray = new byte[m_totalBytes];
        int j;
        for(;i < m_totalBytes;i += j)
        {
            try
            {
                m_request.getInputStream();
                j = m_request.getInputStream().read(m_binArray,i,m_totalBytes - i);
            }
            catch(Exception exception)
            {
                throw new SmartUploadException("Unable to upload.");
            }
        }

        for(;!flag1 && m_currentIndex < m_totalBytes;m_currentIndex++)
        {
            if(m_binArray[m_currentIndex] == 13)
                {
                    s1 = s1 + s3 + s2;
                }
                return s1;
            }
            if(flag)
            {
                throw new IllegalArgumentException("The path is not a virtual path.");
            }
            else
            {
                throw new IllegalArgumentException("This path does not exist (1135).");
            }
        }
        if(i == 2)
        {
            if(flag)
            {
                if(m_denyPhysicalPath)
                {
                    throw new IllegalArgumentException("Physical path is denied (1125).");
                }
                else
                {
                    return s;
                }
            }
            if(isVirtual(s1))
            {
                throw new IllegalArgumentException("The path is not a physical path.");
            }
            else
            {
                throw new IllegalArgumentException("This path does not exist (1135).");
            }
        }
        else
        {
            return null;
        }
    }

    public void uploadInFile(String s) throws IOException,SmartUploadException
    {
        //boolean flag = false;
        int i = 0;
        int j = 0;
        if(s == null)
        {
            throw new IllegalArgumentException("There is no specified destination file (1025).");
public class OrderList2Servlet extends HttpServlet {

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

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

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Validate vd = new Validate();
		String userid = vd.getUnicode(request.getParameter("userid"));
		String bookname = vd.getUnicode(request.getParameter("bookname"));
		String orderda = vd.getUnicode(request.getParameter("orderda"));
		String orderxiao = vd.getUnicode(request.getParameter("orderxiao"));
		String sql = "select a.id as userid,b.id as bookid,c.id as orderid,realname,phone,address,b.name as bookname,booksum,price1,times from users a,books b,orders c where a.id=c.userid and b.id=c.bookid ";
		String[] args = {"userid","bookid","orderid","realname","phone","address","bookname","booksum","price1","times"};
		if(userid != null && !userid.equals("")){
			sql += "and a.id='"+userid+"'";
		}
		if(bookname != null && !bookname.equals("")){
			sql += "and b.name like '%"+bookname+"%'";
		}
		if(orderda != null && !orderda.equals("")){
			sql += "and c.booksum>"+orderda;
		}
		if(orderxiao != null && !orderxiao.equals("")){
			sql += "and c.booksum<"+orderxiao;
		}
		SelectBean sb = new SelectBean();
		ArrayList al = sb.select(sql, args);
		request.setAttribute("order", al);
		RequestDispatcher rd=request.getRequestDispatcher("/admin/order2.jsp");
        rd.forward(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request,response);
	}

	/**
	 * Initialization of the servlet. <br>
	 *
            return s;
        }
    }

    public void setDeniedFilesList(String s) throws ServletException,IOException,SQLException
    {
        //String s1 = "";
        if(s != null)
        {
            String s2 = "";
            for(int i = 0;i < s.length();i++)
            {
                if(s.charAt(i) == ',')
                {
                    if(!m_deniedFilesList.contains(s2))
                    {
                        m_deniedFilesList.addElement(s2);
                    }
                    s2 = "";
                }
                else
                {
                    s2 = s2 + s.charAt(i);
                }
            }

            //if(s2 != "")
            if(!s2.equals(""))
            {
                m_deniedFilesList.addElement(s2);
            }
        }
        else
        {
            m_deniedFilesList = null;
        }
    }

    public void setAllowedFilesList(String s)
    {
        //String s1 = "";
        if(s != null)
        {
            String s2 = "";
            for(int i = 0;i < s.length();i++)
            {
                if(s.charAt(i) == ',')
                {
                    if(!m_allowedFilesList.contains(s2))
                    {
                        m_allowedFilesList.addElement(s2);
                    }
                    s2 = "";
                }
		HttpSession session = request.getSession();
		ArrayList adminlogin = (ArrayList)session.getAttribute("adminlogin");
		ArrayList login = (ArrayList)session.getAttribute("login");
		String id = "";
		if(adminlogin != null && !adminlogin.equals("")){
			id = (String)adminlogin.get(0);
		}
		String userid = "";
		if(login != null && !login.equals("")){
			userid = (String)login.get(0);
		}
		
		if(userpwd != null && userpwd.equals("1")){
			sql = "update [user] set pwd='"+newpwd+"' where id='"+userid+"'";
			str = "/index.jsp";
			ib.insertANDupdateANDdel(sql);
		}else{
			if(xpwd != null && xpwd.equals("1")){
				sql = "update admin set pwd='"+newpwd+"' where id='"+id+"'";
			}
			if(xname != null && xname.equals("1")){
				sql = "update admin set name='"+newname+"' where id='"+id+"'";
			}
			if(xuser != null && xuser.equals("1")){
				sql = "insert into admin(name,pwd) values('"+name+"','"+pwd+"')";
			}
			int flag = ib.insertANDupdateANDdel(sql);
			if(flag == -1){
				request.setAttribute("error", "1");
				str = "/admin/adduser.jsp";
			}else{
				session.removeAttribute("login");
				str = "/admin/index.jsp";
			}
		}
		RequestDispatcher rd=request.getRequestDispatcher(str);
        rd.forward(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值