基于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)
flag1 = true;
j = m_currentIndex - 1;
m_currentIndex = m_currentIndex + 2;
}
else
{
m_currentIndex++;
}
}
String s = new String(m_binArray,i,(j - i) + 1);
return s;
}
private String getFileName(String s)
{
//String s1 = ""; // = new String();
//String s2 = ""; // = new String();
//boolean flag = false;
//boolean flag1 = false;
//boolean flag2 = false;
int i = 0;
i = s.lastIndexOf('/');
if(i != -1)
{
return s.substring(i + 1,s.length());
}
i = s.lastIndexOf('\\');
if(i != -1)
{
return s.substring(i + 1,s.length());
}
else
{
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) == ',')
*/
public void init() throws ServletException {
// Put your code here
}
}
public class ServletUpload extends HttpServlet
{
private ServletConfig config;
/**
* Init the servlet
*/
final public void init(ServletConfig config) throws ServletException
{
this.config = config;
}
final public ServletConfig getServletConfig()
{
return config;
}
/**
* Handles GET requests
*/
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
{
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<BODY BGCOLOR='white'>");
out.println("<H1>jspSmartUpload : Servlet Sample</H1>");
out.println("<HR><BR>");
out.println("The method of the HTML form must be POST.");
out.println("</BODY>");
out.println("</HTML>");
}
/**
{
return;
}
for(m_currentIndex++;m_currentIndex < m_totalBytes;m_currentIndex = m_currentIndex + 2)
{
String s1 = getDataHeader();
m_currentIndex = m_currentIndex + 2;
boolean flag3 = s1.indexOf("filename") > 0;
String s3 = getDataFieldValue(s1,"name");
if(flag3)
{
s6 = getDataFieldValue(s1,"filename");
s4 = getFileName(s6);
s5 = getFileExt(s4);
s7 = getContentType(s1);
s8 = getContentDisp(s1);
s9 = getTypeMIME(s7);
s10 = getSubTypeMIME(s7);
}
getDataSection();
if(flag3 && s4.length() > 0)
{
if(m_deniedFilesList.contains(s5))
{
throw new SecurityException("The extension of the file is denied to be uploaded (1015).");
}
if(!m_allowedFilesList.isEmpty() && !m_allowedFilesList.contains(s5))
{
throw new SecurityException("The extension of the file is not allowed to be uploaded (1010).");
}
if(m_maxFileSize > 0L && (long)((m_endData - m_startData) + 1) > m_maxFileSize)
{
throw new SecurityException("Size exceeded for this file : " + s4 + " (1105).");
}
l += (m_endData - m_startData) + 1;
if(m_totalMaxFileSize > 0L && l > m_totalMaxFileSize)
{
throw new SecurityException("Total File Size exceeded (1110).");
}
}
if(flag3)
{
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);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
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)
{
m_maxFileSize = l;
}
protected String getPhysicalPath(String s,int i) throws IOException
{
String s1 = ""; //new String();
String s2 = ""; //new String();
String s3 = ""; //new String();
boolean flag = false;
s3 = System.getProperty("file.separator");
if(s == null)
{
throw new IllegalArgumentException("There is no specified destination file (1140).");
}
if(s.equals(""))
{
throw new IllegalArgumentException("There is no specified destination file (1140).");
}
if(s.lastIndexOf("\\") >= 0)
{
s1 = s.substring(0,s.lastIndexOf("\\"));
s2 = s.substring(s.lastIndexOf("\\") + 1);
}
if(s.lastIndexOf("/") >= 0)
public class DelServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public DelServlet() {
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 bookid = vd.getUnicode(request.getParameter("id"));
String typeid = vd.getUnicode(request.getParameter("typeid"));
String userid = vd.getUnicode(request.getParameter("userid"));
String leaveword = vd.getUnicode(request.getParameter("leaveword"));
String loanbook = vd.getUnicode(request.getParameter("loanbook"));
String beforehand = vd.getUnicode(request.getParameter("beforehand"));
String nutrition = vd.getUnicode(request.getParameter("nutrition"));
String stock = vd.getUnicode(request.getParameter("stock"));
String emp = vd.getUnicode(request.getParameter("emp"));
InsertUpdateDelBean ib = new InsertUpdateDelBean();
String sql = "";
String str = "";
if(bookid != null && !bookid.equals("")){
str = "/admin/booklist.jsp";
sql = "delete from books where id='"+bookid+"'";
ib.insertANDupdateANDdel(sql);
}
if(typeid != null && !typeid.equals("")){
str = "/admin/typelist.jsp";
sql = "delete from types where id='"+typeid+"'";
s1 = s1 + s3 + s2;
}
return s1;
}
if(flag)
{
if(m_denyPhysicalPath)
{
throw new IllegalArgumentException("Physical path is denied (1125).");
}
else
{
return s;
}
}
else
{
throw new IllegalArgumentException("This path does not exist (1135).");
}
}
if(i == 1)
{
if(isVirtual(s1))
{
s1 = m_application.getRealPath(s1);
if(s1.endsWith(s3))
{
s1 = s1 + s2;
}
else
{
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).");
}
}
* @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();
m_request = (HttpServletRequest)pagecontext.getRequest();
m_response = (HttpServletResponse)pagecontext.getResponse();
}
/**
* @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();
public class StatisticServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public StatisticServlet() {
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 flag = vd.getUnicode(request.getParameter("flag"));
SelectBean sb = new SelectBean();
SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd kk:mm",Locale.getDefault());
Date currentDate = new Date();
String lastdate = formatter.format(currentDate);
if(flag.equals("1")){
String sql = "select b.name as bookname,booksum,price1 from books b,orders c where b.id=c.bookid and SUBSTRING(times,1,10)='"+lastdate.substring(0,10)+"'";
String[] args = {"bookname","booksum","price1"};
ArrayList al = sb.select(sql, args);
request.setAttribute("sell", al);
}
if(flag.equals("2")){
String sql = "select name,unit,sum(sums) as sums,sum(price) as price from stock where SUBSTRING(times,1,10)='"+lastdate.substring(0,10)+"' group by name";
String[] args = {"name","unit","sums","price"};
ArrayList al = sb.select(sql, args);
request.setAttribute("stocks", al);
}
RequestDispatcher rd=request.getRequestDispatcher("/admin/statistic_list.jsp");
rd.forward(request,response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
/**
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}
public class EmpAddServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public EmpAddServlet() {
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 name = vd.getUnicode(request.getParameter("name"));
String sex = vd.getUnicode(request.getParameter("sex"));
String birthday = vd.getUnicode(request.getParameter("birthday"));
String phone = vd.getUnicode(request.getParameter("phone"));
String addr = vd.getUnicode(request.getParameter("addr"));
String duty = vd.getUnicode(request.getParameter("duty"));
String str = "";
String sql = "insert into emp(name,sex,birthday,phone,addr,duty,estate) values('"+name+"','"+sex+"','"+birthday+"','"+phone+"','"+addr+"','"+duty+"','闲置')";
{
throw new IllegalArgumentException("File '" + s + "' not found (1040).");
}
if(s.equals(""))
{
throw new IllegalArgumentException("File '" + s + "' not found (1040).");
}
if(!isVirtual(s) && m_denyPhysicalPath)
{
throw new SecurityException("Physical path is denied (1035).");
}
if(isVirtual(s))
{
s = m_application.getRealPath(s);
}
java.io.File file = new java.io.File(s);
FileInputStream fileinputstream = new FileInputStream(file);
long l = file.length();
//boolean flag = false;
int k = 0;
byte abyte0[] = new byte[i];
if(s1 == null)
{
m_response.setContentType("application/x-msdownload");
}
else
{
if(s1.length() == 0)
{
m_response.setContentType("application/x-msdownload");
}
else
{
m_response.setContentType(s1);
}
}
m_response.setContentLength((int)l);
m_contentDisposition = m_contentDisposition != null ? m_contentDisposition : "attachment;";
if(s2 == null)
{
m_response.setHeader("Content-Disposition",m_contentDisposition + " filename=" + getFileName(s));
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}
public class StatisticServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public StatisticServlet() {
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 flag = vd.getUnicode(request.getParameter("flag"));
}
}
else
{
throw new IllegalArgumentException("This path does not exist (1135).");
}
}
if(i == 1)
{
if(isVirtual(s1))
{
s1 = m_application.getRealPath(s1);
if(s1.endsWith(s3))
{
s1 = s1 + s2;
}
else
{
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
}
}
}
if(del != null && !del.equals("") && shopping !=null && shopping.size()!= 0){
shopping.remove(Integer.parseInt(del));//删除商品
}
session.setAttribute("shopping",shopping);
if(remove != null && !remove.equals("") && session.getAttribute("shopping") != null && !session.getAttribute("shopping").equals("")){
session.removeAttribute("shopping");//清空购物车
}
}
RequestDispatcher rd=request.getRequestDispatcher(str);
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 ListServlet extends HttpServlet {
/**
public class ModifyUserServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public ModifyUserServlet() {
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 pwd = vd.getUnicode(request.getParameter("pwd"));
String age = vd.getUnicode(request.getParameter("age"));
String noid = vd.getUnicode(request.getParameter("noid"));
String address = vd.getUnicode(request.getParameter("address"));
String phone = vd.getUnicode(request.getParameter("phone"));
String email = vd.getUnicode(request.getParameter("email"));
String code = vd.getUnicode(request.getParameter("code"));
String sql = "update users set pwd='"+pwd+"',age='"+age+"',card='"+noid+"',address='"+address+"',phone='"+phone+"',email='"+email+"',code='"+code+"' where id='"+id+"'";
InsertUpdateDelBean ib = new InsertUpdateDelBean();
ib.insertANDupdateANDdel(sql);
}
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 KuXiaoServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public KuXiaoServlet() {
super();
}
}else{
str = "/admin/emp_list.jsp";
request.setAttribute("ok", "1");
}
RequestDispatcher rd = request.getRequestDispatcher(str);
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 OrderListServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public OrderListServlet() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
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 name = vd.getUnicode(request.getParameter("name"));
String sex = vd.getUnicode(request.getParameter("sex"));
String birthday = vd.getUnicode(request.getParameter("birthday"));
String phone = vd.getUnicode(request.getParameter("phone"));
String addr = vd.getUnicode(request.getParameter("addr"));
String duty = vd.getUnicode(request.getParameter("duty"));
String str = "";
String sql = "insert into emp(name,sex,birthday,phone,addr,duty,estate) values('"+name+"','"+sex+"','"+birthday+"','"+phone+"','"+addr+"','"+duty+"','闲置')";
InsertUpdateDelBean ib = new InsertUpdateDelBean();
int flag = ib.insertANDupdateANDdel(sql);
if(flag == -1){
str = "/admin/emp_add.jsp";
request.setAttribute("error", "1");
}else{
str = "/admin/emp_list.jsp";
request.setAttribute("ok", "1");
}
RequestDispatcher rd = request.getRequestDispatcher(str);
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
}
}