package com.zzw.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.zzw.entity.Bill; import com.zzw.service.IUserService; import com.zzw.service.Impl.UserServiceImpl; public class AddBillServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); response.setContentType("text/html; charset=utf-8"); String type= request.getParameter("btype"); int money=Integer.parseInt(request.getParameter("bmoney")); String date= request.getParameter("bdate"); String remark= request.getParameter("bremark"); Bill bill =new Bill(type,money,date,remark); //接口 x=new 实现类() IUserService userservice = new UserServiceImpl(); boolean result=userservice.AddBill(bill); if(!result) { request.setAttribute("message","error"); }else { request.setAttribute("message","noerror"); } request.getRequestDispatcher("add.jsp").forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } } package com.zzw.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.zzw.service.IUserService; import com.zzw.service.Impl.UserServiceImpl; public class DeleteBillServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); response.setContentType("text/html; charset=utf-8"); int id= Integer.parseInt(request.getParameter("bid")); IUserService userservice = new UserServiceImpl(); boolean result=userservice.DeleteBill(id); if(!result) { request.setAttribute("message","error"); }else { request.setAttribute("message","noerror"); } request.getRequestDispatcher("QueryAllBillServlet").forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } } package com.zzw.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.zzw.entity.User; import com.zzw.service.IUserService; import com.zzw.service.Impl.UserServiceImpl; public class LoginServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); response.setContentType("text/html; charset=utf-8"); String name= request.getParameter("uname"); String pwd= request.getParameter("upwd"); User user = new User(name,pwd); //接口 x=new 实现类() IUserService userservice = new UserServiceImpl(); boolean result=userservice.Login(user); if(!result) { request.setAttribute("message","error"); request.getRequestDispatcher("login.jsp").forward(request, response); }else { request.setAttribute("message","noerror"); request.getRequestDispatcher("index.jsp").forward(request, response); } } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } } package com.zzw.servlet; import java.io.IOException; import java.io.PrintWriter; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.zzw.entity.Bill; import com.zzw.service.IUserService; import com.zzw.service.Impl.UserServiceImpl; public class QueryAllBillServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); response.setContentType("text/html; charset=utf-8"); IUserService userservice = new UserServiceImpl(); List <Bill> Bills = userservice.QueryAll (); // OUT target acquisition method of the PrintWriter OUT = response.getWriter (); request.setAttribute("bills", bills); request.getRequestDispatcher("show.jsp").forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } } package com.zzw.servlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.zzw.entity.Bill; import com.zzw.service.IUserService; import com.zzw.service.Impl.UserServiceImpl; public class QueryBillServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); the response.setContentType ( "text / HTML; charset = UTF-. 8" ); // Get be queried modified human student number int ID = the Integer.parseInt (request.getParameter ( "Bid" )); IUserService userservice = new UserServiceImpl(); Bill Bill = userservice.Query (ID); // Get out the method object the PrintWriter out = response.getWriter (); out.println(bill); request.setAttribute("bill", bill); request.getRequestDispatcher("billinfo.jsp").forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } } package com.zzw.servlet; import java.io.IOException; import java.io.PrintWriter; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.zzw.entity.Bill; import com.zzw.service.IUserService; import com.zzw.service.Impl.UserServiceImpl; public class QueryDateServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); response.setContentType("text/html; charset=utf-8"); String date=request.getParameter("bdate"); IUserService userservice = new UserServiceImpl(); List <Bill> Bills = userservice.QueryDate (DATE); // OUT target acquisition method of the PrintWriter OUT = response.getWriter (); request.setAttribute("bills", bills); request.getRequestDispatcher("screendate.jsp").forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } } package com.zzw.servlet; import java.io.IOException; import java.io.PrintWriter; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.zzw.entity.Bill; import com.zzw.service.IUserService; import com.zzw.service.Impl.UserServiceImpl; public class QueryPartBillServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); response.setContentType("text/html; charset=utf-8"); String type=request.getParameter("btype"); String date=request.getParameter("bdate"); System.out.println(type+date); IUserService userservice = new UserServiceImpl(); List <Bill> Bills = userservice.QueryPart (type, DATE); // OUT target acquisition method of the PrintWriter OUT = response.getWriter (); request.setAttribute("bills", bills); request.getRequestDispatcher("screen.jsp").forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } } package com.zzw.servlet; import java.io.IOException; import java.io.PrintWriter; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.zzw.entity.Bill; import com.zzw.service.IUserService; import com.zzw.service.Impl.UserServiceImpl; public class QueryTypeServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); response.setContentType("text/html; charset=utf-8"); String type=request.getParameter("btype"); IUserService userservice = new UserServiceImpl(); List <Bill> Bills = userservice.QueryType (type); // OUT target acquisition method of the PrintWriter OUT = response.getWriter (); request.setAttribute("bills", bills); request.getRequestDispatcher("screentype.jsp").forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } } package com.zzw.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.zzw.entity.User; import com.zzw.service.IUserService; import com.zzw.service.Impl.UserServiceImpl; public class RegisterServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); response.setContentType("text/html; charset=utf-8"); String name= request.getParameter("uname"); String pwd= request.getParameter("upwd"); String sex= request.getParameter("usex"); User user = new User(name,pwd,sex); //接口 x=new 实现类() IUserService userservice = new UserServiceImpl(); boolean result=userservice.Register(user); if(!result) { request.setAttribute("message","error"); request.getRequestDispatcher("register.jsp").forward(request, response); }else { request.setAttribute("message","noerror"); request.getRequestDispatcher("register.jsp").forward(request, response); } } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } } package com.zzw.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.zzw.entity.Bill; import com.zzw.service.IUserService; import com.zzw.service.Impl.UserServiceImpl; public class UpdateBillServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); the response.setContentType ( "text / HTML; charset = UTF-. 8" ); // Science acquired number of people to be modified int ID = the Integer.parseInt (request.getParameter ( "Bid" )); // Get the modified content request.getParameter of the type = String ( "btype" ); int Money = Integer.parseInt (request.getParameter ( "bmoney" )); String date= request.getParameter("bdate"); The remark String = request.getParameter ( "bremark" ); // the modified content package to a class entity Bill Bill = new new Bill (type, Money, DATE, the remark); IUserService userservice = new UserServiceImpl(); boolean result=userservice.UpdateBill(id,bill); if(!result) { request.setAttribute("message","error"); }else { request.setAttribute("message","noerror"); } request.getRequestDispatcher("QueryAllBillServlet").forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }
Household account book servlet container as part of the class