基于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)
while((long)k < l)
{
int j = fileinputstream.read(abyte0,0,i);
k += j;
m_response.getOutputStream().write(abyte0,0,j);
}
fileinputstream.close();
}
public void downloadField(ResultSet resultset,String s,String s1,String s2) throws ServletException,IOException,SQLException
{
if(resultset == null)
{
throw new IllegalArgumentException("The RecordSet cannot be null (1045).");
}
if(s == null)
{
throw new IllegalArgumentException("The columnName cannot be null (1050).");
}
if(s.length() == 0)
{
throw new IllegalArgumentException("The columnName cannot be empty (1055).");
}
byte abyte0[] = resultset.getBytes(s);
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(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);
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
}
}
package com.demo.servlet.admin;
/**
* 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);
}
/**
}
}
public int save(String s) throws ServletException,IOException,SmartUploadException
{
return save(s,0);
}
public int save(String s,int i) throws ServletException,IOException,SmartUploadException
{
int j = 0;
if(s == null)
{
s = m_application.getRealPath("/");
//System.out.println("s == null,m_application.getRealPath:" + s);
}
if(s.indexOf("/") != -1)
{
if(s.charAt(s.length() - 1) != '/')
{
s = s + "/";
//System.out.println("m_application.getRealPath::" + s);
}
}
else
{
if(s.charAt(s.length() - 1) != '\\')
{
s = s + "\\";
//System.out.println("m_application.getRealPath" + s);
}
}
//System.out.println("m_application.getRealPath:::" + s);
FileNames = new String[m_files.getCount()];
for(int k = 0;k < m_files.getCount();k++)
{
if(!m_files.getFile(k).isMissing())
{
//System.out.println("s + m_files.getFile(k).getFileName():" + s + m_files.getFile(k).getFileName());
m_files.getFile(k).saveAs(s + m_files.getFile(k).getFileName(),i);
FileNames[j] = s + m_files.getFile(k).getFileName();
j++;
}
}
return j;
}
}
if(isVirtual(s))
{
s = m_application.getRealPath(s);
}
try
{
java.io.File file = new java.io.File(s);
FileOutputStream fileoutputstream = new FileOutputStream(file);
fileoutputstream.write(m_binArray);
fileoutputstream.close();
}
catch(Exception exception1)
{
throw new SmartUploadException("The Form cannot be saved in the specified file (1030).");
}
}
private boolean isVirtual(String s)
{
if(m_application.getRealPath(s) != null)
{
java.io.File file = new java.io.File(m_application.getRealPath(s));
return file.exists();
}
else
{
return false;
}
}
}
package com.demo.servlet.qiantai;
int i = m_currentIndex;
int j = 0;
for(boolean flag1 = false;!flag1;)
{
if(m_binArray[m_currentIndex] == 13 && m_binArray[m_currentIndex + 2] == 13)
{
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 = "";
InsertUpdateDelBean ib = new InsertUpdateDelBean();
SelectBean sb = new SelectBean();
ArrayList login = (ArrayList)session.getAttribute("login");
String str = "";
String sql = "update books set storage=storage-1 where id="+bookid;
int flag = ib.insertANDupdateANDdel(sql);
if(flag == -1){
str = "/qiantai/loan_book.jsp";
request.setAttribute("error1", "1");
request.setAttribute("bookId", bookid);
}else{
sql = "select * from loanbook where users='"+login.get(0)+"' and books='"+bookid+"' and flag='未点菜'";
String[] args = {"id","users","books","price","sumday","begintime","endtime","continueday","continuetime","flag"};
ArrayList al = sb.select(args, sql);
if(al != null && al.size() != 0){
str = "/qiantai/loan_book.jsp";
request.setAttribute("error2", "1");
request.setAttribute("bookId", bookid);
}else{
sql = "insert into loanbook(users,books,price,sumday) values('"+login.get(0)+"','"+bookid+"','"+price+"','"+sumday+"')";
ib.insertANDupdateANDdel(sql);
sql = "select max(id) as id from loanbook";
String[] args1 = {"id"};
ArrayList al1 = sb.select(args1, sql);
sql = "update loanbook set endtime=dateadd(day,"+sumday+",begintime) where id="+al1.get(0);
ib.insertANDupdateANDdel(sql);
sql = "update books set sums=sums+1 where id="+bookid;
ib.insertANDupdateANDdel(sql);
str = "/qiantai/loan_book_note.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>
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+"','闲置')";
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);
}
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
}
}
package com.demo.servlet.admin;
public class KuXiaoServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public KuXiaoServlet() {
super();
}
/**
* Destruction of the servlet. <br>
*/
downloadFile(s,s1,s2,65000);
}
public void downloadFile(String s,String s1,String s2,int i) throws ServletException,IOException,SmartUploadException
{
if(s == null)
{
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);
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 {
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);
public class LoanBookServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public LoanBookServlet() {
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("bookid"));
String sumday = vd.getUnicode(request.getParameter("sumday"));
String price = vd.getUnicode(request.getParameter("price"));
HttpSession session = request.getSession();
InsertUpdateDelBean ib = new InsertUpdateDelBean();
SelectBean sb = new SelectBean();
ArrayList login = (ArrayList)session.getAttribute("login");
String str = "";
String sql = "update books set storage=storage-1 where id="+bookid;
int flag = ib.insertANDupdateANDdel(sql);
if(flag == -1){
str = "/qiantai/loan_book.jsp";
request.setAttribute("error1", "1");
request.setAttribute("bookId", bookid);
}else{
sql = "select * from loanbook where users='"+login.get(0)+"' and books='"+bookid+"' and flag='未点菜'";
String[] args = {"id","users","books","price","sumday","begintime","endtime","continueday","continuetime","flag"};
ArrayList al = sb.select(args, sql);
if(al != null && al.size() != 0){
str = "/qiantai/loan_book.jsp";
}
}
package com.demo.servlet.qiantai;
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"));
String content = vd.getUnicode(request.getParameter("content"));
HttpSession session = request.getSession();
ArrayList login = (ArrayList)session.getAttribute("login");
SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd kk:mm",Locale.getDefault());
Date currentDate = new Date();
String lastdate = formatter.format(currentDate);
String sql = "insert into leaveword(users,title,content,times) values('"+login.get(0)+"','"+title+"','"+content+"','"+lastdate+"')";
InsertUpdateDelBean ib = new InsertUpdateDelBean();
ib.insertANDupdateANDdel(sql);
}
}
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).");
ArrayList al = sb.select(args, sql);
if(al != null && al.size() != 0){
str = "/qiantai/loan_book.jsp";
request.setAttribute("error2", "1");
request.setAttribute("bookId", bookid);
}else{
sql = "insert into loanbook(users,books,price,sumday) values('"+login.get(0)+"','"+bookid+"','"+price+"','"+sumday+"')";
ib.insertANDupdateANDdel(sql);
sql = "select max(id) as id from loanbook";
String[] args1 = {"id"};
ArrayList al1 = sb.select(args1, sql);
sql = "update loanbook set endtime=dateadd(day,"+sumday+",begintime) where id="+al1.get(0);
ib.insertANDupdateANDdel(sql);
sql = "update books set sums=sums+1 where id="+bookid;
ib.insertANDupdateANDdel(sql);
str = "/qiantai/loan_book_note.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
}
}
package com.demo.servlet.admin;
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)
{
SmartFile file = new SmartFile();
file.setParent(this);
file.setFieldName(s3);
file.setFileName(s4);
file.setFileExt(s5);
file.setFilePathName(s6);
file.setIsMissing(s6.length() == 0);
file.setContentType(s7);
file.setContentDisp(s8);
file.setTypeMIME(s9);
file.setSubTypeMIME(s10);
if(s7.indexOf("application/x-macbinary") > 0)
{
m_startData = m_startData + 128;
}
file.setSize((m_endData - m_startData) + 1);
file.setStartData(m_startData);
file.setEndData(m_endData);
m_files.addFile(file);
}
else
{
String s11 = new String(m_binArray,m_startData,(m_endData - m_startData) + 1);
m_formRequest.putParameter(s3,s11);
}
if((char)m_binArray[m_currentIndex + 1] == '-')
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);
}
}
//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)
}
package com.demo.servlet.qiantai;
public class RegServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public RegServlet() {
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 pwd = vd.getUnicode(request.getParameter("pwd"));
String zname = vd.getUnicode(request.getParameter("zname"));
String sex = vd.getUnicode(request.getParameter("sex"));
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"));
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");
/**
* @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();
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;
{
m_startData = m_startData + 128;
}
file.setSize((m_endData - m_startData) + 1);
file.setStartData(m_startData);
file.setEndData(m_endData);
m_files.addFile(file);
}
else
{
String s11 = new String(m_binArray,m_startData,(m_endData - m_startData) + 1);
m_formRequest.putParameter(s3,s11);
}
if((char)m_binArray[m_currentIndex + 1] == '-')
{
break;
}
}
}
public int save(String s) throws ServletException,IOException,SmartUploadException
{
return save(s,0);
}
public int save(String s,int i) throws ServletException,IOException,SmartUploadException
{
int j = 0;
if(s == null)
{
s = m_application.getRealPath("/");
//System.out.println("s == null,m_application.getRealPath:" + s);
}
if(s.indexOf("/") != -1)
{
if(s.charAt(s.length() - 1) != '/')
{
s = s + "/";
//System.out.println("m_application.getRealPath::" + s);
}
}
else
{
if(s.charAt(s.length() - 1) != '\\')
{
s = s + "\\";
//System.out.println("m_application.getRealPath" + s);
}
}
//System.out.println("m_application.getRealPath:::" + s);
FileNames = new String[m_files.getCount()];
for(int k = 0;k < m_files.getCount();k++)
{
}
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
}
}
package com.demo.servlet;
public class ListServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public ListServlet() {
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 {
InsertUpdateDelBean ib = new InsertUpdateDelBean();
int flag = ib.insertANDupdateANDdel(sql);
if(flag == -1){
request.setAttribute("error", "1");
}else{
request.setAttribute("ok", "1");
response.setHeader("Refresh","5;URL=../qiantai/index.jsp");
}
RequestDispatcher rd=request.getRequestDispatcher("/qiantai/reg.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
}
}
package com.demo.servlet.admin;
public class OrderList2Servlet extends HttpServlet {
/**
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}
package com.demo.smartupload;
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 OrderListServlet() {
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 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
}
}
package com.demo.servlet.admin;
/**
* 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"));
String content = vd.getUnicode(request.getParameter("content"));
HttpSession session = request.getSession();
ArrayList login = (ArrayList)session.getAttribute("login");
SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd kk:mm",Locale.getDefault());
Date currentDate = new Date();
String lastdate = formatter.format(currentDate);
String sql = "insert into leaveword(users,title,content,times) values('"+login.get(0)+"','"+title+"','"+content+"','"+lastdate+"')";
InsertUpdateDelBean ib = new InsertUpdateDelBean();
ib.insertANDupdateANDdel(sql);
request.setAttribute("ok", "1");
RequestDispatcher rd=request.getRequestDispatcher("/qiantai/leave_word.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
}
}
package com.demo.servlet.admin;