util包:
DBUtil.java
package util; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import entity.Doc; import entity.Permission; import entity.Users; /** * * @author twj * */ public class DBUtil { private static String db_url = "jdbc:mysql://localhost:3306/test3?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC"; public static String db_user = "root"; public static String db_pass = "123"; public static Connection getConn () { Connection conn = null; try { Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection(db_url, db_user, db_pass); } catch (Exception e) { e.printStackTrace(); } return conn; } /** * �ر����� * @param state * @param conn */ public static void close (Statement state, Connection conn) { if (state != null) { try { state.close(); } catch (SQLException e) { e.printStackTrace(); } } if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } public static void close (ResultSet rs, Statement state, Connection conn) { if (rs != null) { try { rs.close(); } catch (SQLException e) { e.printStackTrace(); } } if (state != null) { try { state.close(); } catch (SQLException e) { e.printStackTrace(); } } if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } //某表的增删改查 public static ArrayList<Doc> getDoces(String type) { Connection connection=null; PreparedStatement preparedStatement=null; ResultSet rSet=null; try { connection=getConn(); String sql; System.out.println(type); if(type.equals("receive")) { sql="select * from doc_list where status=0 or status=2 or status=3 or status=6 or status=7 or status=-1 and deletestatus=0"; } else if(type.equals("send")) { sql="select * from doc_list where status=1 or status=4 or status=5 or status=8 or status=9 or status=10 and deletestatus=0"; } else if(type.equals("delete")) { sql="select * from doc_list where delete status=1"; } else { sql="select * from doc_list"; } preparedStatement=connection.prepareStatement(sql); rSet=preparedStatement.executeQuery(); ArrayList<Doc> list=new ArrayList<>(); while(rSet.next()) { Doc doc=new Doc(); doc.setId(rSet.getInt("id")); doc.setTitle(rSet.getString("title")); doc.setOwner(rSet.getString("owner")); doc.setTime(rSet.getString("time")); doc.setReceiver(rSet.getString("receiver")); doc.setStatus(rSet.getInt("status")); doc.setResult(rSet.getInt("result")); doc.setPlace(rSet.getString("place")); doc.setDeletestatus(rSet.getInt("deletestatus")); list.add(doc); } return list; } catch (SQLException e) { // TODO: handle exception e.printStackTrace(); } finally { close(rSet, preparedStatement, connection); } return null; } //登录时验证数据库中账户是否存在 public static boolean log_isExist(Users user) { Connection con=null; PreparedStatement pstmt=null; ResultSet rs=null; try { con=getConn(); String sql_query="select * from users where username = '"+user.getUsername()+"' and password = '"+user.getPassword()+"' and status != 0"; System.out.println(sql_query); pstmt=con.prepareStatement(sql_query); rs=pstmt.executeQuery(); if(rs.next()==false) { System.out.println("用户名或密码错误"); return false; } else { System.out.println("用户名及密码正确"); return true; } } catch (SQLException e) { System.out.println("未连接"); e.printStackTrace(); } finally { close(rs, pstmt, con); } return false; } //增加公文 public static boolean add_doc(Doc doc) { Connection con=null; PreparedStatement pstmt=null; ResultSet rs=null; try { con=getConn(); String sql="insert into doc_list(title,owner,receiver,time,status,result,place,deletestatus,callback) values(?,?,?,?,?,?,?,?,?)"; pstmt=con.prepareStatement(sql); pstmt.setString(1, doc.getTitle()); pstmt.setString(2, doc.getOwner()); pstmt.setString(3, doc.getReceiver()); pstmt.setString(4, doc.getTime()); pstmt.setInt(5, doc.getStatus()); pstmt.setInt(6, doc.getResult()); pstmt.setString(7, doc.getPlace()); pstmt.setInt(8, 0); pstmt.setInt(9, 0); pstmt.executeUpdate(); return true; } catch (SQLException e) { System.out.println("注册失败"); e.printStackTrace(); } finally { close(rs, pstmt, con); } return false; } //删除数据 public static boolean delete_user(Users user) { Connection con=null; PreparedStatement pstmt=null; try { con=getConn(); String sql="delete from users where id="+user.getId(); System.out.println(sql); pstmt=con.prepareStatement(sql); pstmt.executeUpdate(); return true; } catch(SQLException e) { e.printStackTrace(); } finally { close(pstmt, con); } return false; } public static boolean update_userstatus(Users user) { Connection con=null; PreparedStatement pstmt=null; try { con=getConn(); String sql="update users set status = ? where id = ?"; pstmt=con.prepareStatement(sql); pstmt.setInt(1, user.getStatus()); pstmt.setInt(2, user.getId()); pstmt.executeUpdate(); return true; } catch(SQLException e) { e.printStackTrace(); } finally { close(pstmt, con); } return false; } public static boolean update_user(Users user) { Connection con=null; PreparedStatement pstmt=null; try { con=getConn(); String sql="update users set username=?,password=?,job=? where id = "+user.getId(); pstmt=con.prepareStatement(sql); pstmt.setString(1, user.getUsername()); pstmt.setString(2, user.getPassword()); pstmt.setString(3, user.getJob()); pstmt.executeUpdate(); return true; } catch(SQLException e) { e.printStackTrace(); } finally { close(pstmt, con); } return false; } @SuppressWarnings("resource") public static boolean sendDoc(int id) { Connection con=null; PreparedStatement pstmt=null; ResultSet rSet=null; int status=-1; int newstatus=-1; String receiver=""; try { con=DBUtil.getConn(); String sql_query="select * from doc_list where id="+id; pstmt=con.prepareStatement(sql_query); rSet=pstmt.executeQuery(); if(rSet.next()) { status=rSet.getInt("status"); } switch (status) { case 0: newstatus=1; receiver="副厂长"; break; case 2: newstatus=5; receiver="厂长"; break; case 3: newstatus=4; receiver="部门"; break; case 6: newstatus=8; receiver="部门和副厂长"; break; case 7: newstatus=9; receiver="部门和副厂长"; break; case 8: newstatus=10; receiver="部门"; break; default: System.out.println("公文状态有误!"); break; } String sql_update="update doc_list set status = ? where id = ?"; pstmt=con.prepareStatement(sql_update); pstmt.setInt(1, newstatus); pstmt.setInt(2, id); pstmt.executeUpdate(); return true; } catch (SQLException e) { System.out.println("数据库信息更新失败"); e.printStackTrace(); } finally { close(pstmt, con); } return false; } public static ArrayList<Doc> getDocesByCase(String type,String value) { Connection connection=null; PreparedStatement preparedStatement=null; ResultSet rSet=null; try { connection=getConn(); String sql=""; System.out.println(type); if(type.equals("title")) { sql="select * from doc_list where title='"+value+"'"; } else if(type.equals("owner")) { sql="select * from doc_list where owner='"+value+"'"; } else if(type.equals("receiver")) { sql="select * from doc_list where receiver='"+value+"'"; } else if(type.equals("result")) { sql="select * from doc_list where result='"+value+"'"; } preparedStatement=connection.prepareStatement(sql); rSet=preparedStatement.executeQuery(); ArrayList<Doc> list=new ArrayList<>(); while(rSet.next()) { Doc doc=new Doc(); doc.setId(rSet.getInt("id")); doc.setTitle(rSet.getString("title")); doc.setOwner(rSet.getString("owner")); doc.setTime(rSet.getString("time")); doc.setReceiver(rSet.getString("receiver")); doc.setStatus(rSet.getInt("status")); doc.setResult(rSet.getInt("result")); doc.setPlace(rSet.getString("place")); list.add(doc); } return list; } catch (SQLException e) { // TODO: handle exception e.printStackTrace(); } finally { close(rSet, preparedStatement, connection); } return null; } public static ArrayList<Doc> getCheckedorNot(String type) { Connection connection=null; PreparedStatement preparedStatement=null; ResultSet rSet=null; try { connection=getConn(); String sql=""; System.out.println(type); if(type.equals("notchecked")) { sql="select * from doc_list where status=1"; } else { sql="select * from doc_list where status!=1 and status!=0 and status!=-1"; } preparedStatement=connection.prepareStatement(sql); rSet=preparedStatement.executeQuery(); ArrayList<Doc> list=new ArrayList<>(); while(rSet.next()) { Doc doc=new Doc(); doc.setId(rSet.getInt("id")); doc.setTitle(rSet.getString("title")); doc.setOwner(rSet.getString("owner")); doc.setTime(rSet.getString("time")); doc.setReceiver(rSet.getString("receiver")); doc.setStatus(rSet.getInt("status")); doc.setResult(rSet.getInt("result")); doc.setPlace(rSet.getString("place")); list.add(doc); } return list; } catch (SQLException e) { // TODO: handle exception e.printStackTrace(); } finally { close(rSet, preparedStatement, connection); } return null; } public static ArrayList<Doc> getFcheckedorNot(String type) { Connection connection=null; PreparedStatement preparedStatement=null; ResultSet rSet=null; try { connection=getConn(); String sql=""; if(type.equals("checked")) { sql="select * from doc_list where status=6 or status=7"; } else { sql="select * from doc_list where status=5"; } preparedStatement=connection.prepareStatement(sql); rSet=preparedStatement.executeQuery(); ArrayList<Doc> list=new ArrayList<>(); while(rSet.next()) { Doc doc=new Doc(); doc.setId(rSet.getInt("id")); doc.setTitle(rSet.getString("title")); doc.setOwner(rSet.getString("owner")); doc.setTime(rSet.getString("time")); doc.setReceiver(rSet.getString("receiver")); doc.setStatus(rSet.getInt("status")); doc.setResult(rSet.getInt("result")); doc.setPlace(rSet.getString("place")); list.add(doc); } return list; } catch (SQLException e) { // TODO: handle exception e.printStackTrace(); } finally { close(rSet, preparedStatement, connection); } return null; } public static ArrayList<Doc> getReceivedByUser(String type,Users user) { Connection connection=null; PreparedStatement preparedStatement=null; ResultSet rSet=null; try { connection=getConn(); String sql=""; if(type.equals("received")) { sql="select * from doc_list where owner=? and status=10"; } else { sql="select * from doc_list where owner=? and status!=10"; } preparedStatement=connection.prepareStatement(sql); preparedStatement.setString(1, user.getUsername()); rSet=preparedStatement.executeQuery(); ArrayList<Doc> list=new ArrayList<>(); while(rSet.next()) { Doc doc=new Doc(); doc.setId(rSet.getInt("id")); doc.setTitle(rSet.getString("title")); doc.setTime(rSet.getString("time")); doc.setStatus(rSet.getInt("status")); doc.setResult(rSet.getInt("result")); list.add(doc); } return list; } catch (SQLException e) { // TODO: handle exception e.printStackTrace(); } finally { close(rSet, preparedStatement, connection); } return null; } public static Doc getDocById(Doc doc) { Connection connection=null; PreparedStatement preparedStatement=null; ResultSet rSet=null; try { connection=getConn(); String sql="select * from doc_list where id="+doc.getId(); preparedStatement=connection.prepareStatement(sql); rSet=preparedStatement.executeQuery(); if(rSet.next()) { doc.setTitle(rSet.getString("title")); doc.setOwner(rSet.getString("owner")); doc.setTime(rSet.getString("time")); doc.setReceiver(rSet.getString("receiver")); doc.setStatus(rSet.getInt("status")); doc.setResult(rSet.getInt("result")); doc.setPlace(rSet.getString("place")); doc.setTipplace(rSet.getString("tipplace")); doc.setFtipplace(rSet.getString("tipfplace")); return doc; } } catch (SQLException e) { // TODO: handle exception e.printStackTrace(); } finally { close(rSet, preparedStatement, connection); } return null; } public static boolean checked_change(Doc doc) { Connection connection=null; PreparedStatement preparedStatement=null; String sql_update="update doc_list set status = ?,result = ?,receiver = ?,tipplace = ? where id = ?"; try { connection=getConn(); preparedStatement=connection.prepareStatement(sql_update); preparedStatement.setInt(1, doc.getStatus()); preparedStatement.setInt(2, doc.getResult()); preparedStatement.setString(3, doc.getReceiver()); preparedStatement.setString(4, doc.getTipplace()); preparedStatement.setInt(5, doc.getId()); preparedStatement.executeUpdate(); return true; } catch (SQLException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } finally { close(preparedStatement, connection); } return false; } public static boolean fchecked_change(Doc doc) { Connection connection=null; PreparedStatement preparedStatement=null; String sql_update="update doc_list set status = ?,result = ?,receiver = ?,tipfplace = ? where id = ?"; try { connection=getConn(); preparedStatement=connection.prepareStatement(sql_update); preparedStatement.setInt(1, doc.getStatus()); preparedStatement.setInt(2, doc.getResult()); preparedStatement.setString(3, doc.getReceiver()); preparedStatement.setString(4, doc.getFtipplace()); preparedStatement.setInt(5, doc.getId()); preparedStatement.executeUpdate(); return true; } catch (SQLException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } finally { close(preparedStatement, connection); } return false; } public static boolean formatDoc(Doc doc) { Connection connection=null; PreparedStatement preparedStatement=null; String sql_update="update doc_list set status = ? where id = ?"; try { connection=getConn(); preparedStatement=connection.prepareStatement(sql_update); preparedStatement.setInt(1, doc.getStatus()); preparedStatement.setInt(2, doc.getId()); preparedStatement.executeUpdate(); return true; } catch (SQLException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } finally { close(preparedStatement, connection); } return false; } public static boolean ReceiveDoc(Doc doc) { Connection connection=null; PreparedStatement preparedStatement=null; String sql_update="update doc_list set status = ?,callback = 1 where id = ?"; try { connection=getConn(); preparedStatement=connection.prepareStatement(sql_update); preparedStatement.setInt(1, 10); preparedStatement.setInt(2, doc.getId()); preparedStatement.executeUpdate(); return true; } catch (SQLException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } finally { close(preparedStatement, connection); } return false; } public static ArrayList<Doc> getDocByTime(Doc doc1,Doc doc2) { Connection connection=null; PreparedStatement preparedStatement=null; ResultSet rs=null; String sql="select * from doc_list where time between ? and ?"; try { connection=getConn(); preparedStatement=connection.prepareStatement(sql); preparedStatement.setString(1,doc1.getTime()); preparedStatement.setString(2, doc2.getTime()); rs=preparedStatement.executeQuery(); ArrayList<Doc> list=new ArrayList<>(); while(rs.next()) { Doc doc=new Doc(); doc.setId(rs.getInt("id")); doc.setTitle(rs.getString("title")); doc.setTime(rs.getString("time")); doc.setOwner(rs.getString("owner")); list.add(doc); } return list; } catch (SQLException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } finally { close(preparedStatement, connection); } return null; } public static ArrayList<Doc> getAllDoc() { Connection connection=null; PreparedStatement preparedStatement=null; ResultSet rs=null; String sql="select * from doc_list"; try { connection=getConn(); preparedStatement=connection.prepareStatement(sql); rs=preparedStatement.executeQuery(); ArrayList<Doc> list=new ArrayList<>(); while(rs.next()) { Doc doc=new Doc(); doc.setId(rs.getInt("id")); doc.setTitle(rs.getString("title")); doc.setTime(rs.getString("time")); doc.setOwner(rs.getString("owner")); list.add(doc); } return list; } catch (SQLException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } finally { close(preparedStatement, connection); } return null; } public static ArrayList<Users> getAllUser() { Connection connection=null; PreparedStatement preparedStatement=null; ResultSet rs=null; String sql="select * from users"; try { connection=getConn(); preparedStatement=connection.prepareStatement(sql); rs=preparedStatement.executeQuery(); ArrayList<Users> list=new ArrayList<>(); while(rs.next()) { Users user=new Users(); user.setId(rs.getInt("id")); user.setUsername(rs.getString("username")); user.setPassword(rs.getString("password")); user.setPermissionId(rs.getInt("permissionId")); user.setJob(rs.getString("job")); user.setStatus(rs.getInt("status")); list.add(user); } return list; } catch (SQLException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } finally { close(preparedStatement, connection); } return null; } public static Users getUserById(Users user) { Connection connection=null; PreparedStatement preparedStatement=null; ResultSet rs=null; String sql="select * from users where id="+user.getId(); try { connection=getConn(); preparedStatement=connection.prepareStatement(sql); rs=preparedStatement.executeQuery(); Users user1=new Users(); if(rs.next()) { user1.setId(rs.getInt("id")); user1.setUsername(rs.getString("username")); user1.setPassword(rs.getString("password")); user1.setPermissionId(rs.getInt("permissionId")); user1.setStatus(rs.getInt("status")); user1.setJob(rs.getString("job")); } return user1; } catch (SQLException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } finally { close(preparedStatement, connection); } return null; } public static ArrayList<Permission> getPermission(Permission permission) { Connection connection=null; PreparedStatement preparedStatement=null; ResultSet rs=null; String sql="select * from permission where id="+permission.getId(); try { connection=getConn(); preparedStatement=connection.prepareStatement(sql); rs=preparedStatement.executeQuery(); ArrayList<Permission> list=new ArrayList<>(); while(rs.next()) { Permission permission1=new Permission(); permission1.setId(rs.getInt("id")); permission1.setPermission(rs.getInt("permission")); list.add(permission1); } return list; } catch (SQLException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } finally { close(preparedStatement, connection); } return null; } public static boolean deletePermission(Permission permission) { Connection con=null; PreparedStatement pstmt=null; try { con=getConn(); String sql="delete from permission where id="+permission.getId(); System.out.println(sql); pstmt=con.prepareStatement(sql); pstmt.executeUpdate(); return true; } catch(SQLException e) { e.printStackTrace(); } finally { close(pstmt, con); } return false; } public static boolean updatePermission(Permission permission1,Permission permission2) { Connection con=null; PreparedStatement pstmt=null; try { con=getConn(); String sql="update permission set permission = ? where id = ? and permission = ?"; pstmt=con.prepareStatement(sql); pstmt.setInt(1, permission2.getPermission()); pstmt.setInt(2, permission1.getId()); pstmt.setInt(3, permission1.getPermission()); pstmt.executeUpdate(); return true; } catch(SQLException e) { e.printStackTrace(); } finally { close(pstmt, con); } return false; } public static boolean updatePwd(Users user) { Connection con=null; PreparedStatement pstmt=null; try { con=getConn(); String sql="update users set password = ? where username = ?"; pstmt=con.prepareStatement(sql); pstmt.setString(1, user.getPassword()); pstmt.setString(2, user.getUsername()); pstmt.executeUpdate(); return true; } catch(SQLException e) { e.printStackTrace(); } finally { close(pstmt, con); } return false; } public static Users getUserByUsername(Users user) { Connection connection=null; PreparedStatement preparedStatement=null; ResultSet rs=null; String sql="select * from users where username='"+user.getUsername()+"'"; try { connection=getConn(); preparedStatement=connection.prepareStatement(sql); rs=preparedStatement.executeQuery(); Users user1=new Users(); if(rs.next()) { user1.setId(rs.getInt("id")); user1.setPermissionId(rs.getInt("permissionId")); System.out.println(user1.getPermissionId()); } return user1; } catch (SQLException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } finally { close(preparedStatement, connection); } return null; } public static boolean deleteDoc(Doc doc) { Connection con=null; PreparedStatement pstmt=null; try { con=getConn(); String sql="update doc_list set deletestatus = ? where id = ?"; pstmt=con.prepareStatement(sql); pstmt.setInt(1, doc.getDeletestatus()); pstmt.setInt(2, doc.getId()); pstmt.executeUpdate(); return true; } catch(SQLException e) { e.printStackTrace(); } finally { close(pstmt, con); } return false; } public static ArrayList<Doc> getCall() { Connection connection=null; PreparedStatement preparedStatement=null; ResultSet rSet=null; try { connection=getConn(); String sql="select * from doc_list where callback=1"; preparedStatement=connection.prepareStatement(sql); rSet=preparedStatement.executeQuery(); ArrayList<Doc> list=new ArrayList<>(); while(rSet.next()) { Doc doc=new Doc(); doc.setId(rSet.getInt("id")); doc.setTitle(rSet.getString("title")); doc.setOwner(rSet.getString("owner")); doc.setTime(rSet.getString("time")); doc.setReceiver(rSet.getString("receiver")); doc.setStatus(rSet.getInt("status")); doc.setResult(rSet.getInt("result")); doc.setPlace(rSet.getString("place")); doc.setDeletestatus(rSet.getInt("deletestatus")); doc.setCallback(rSet.getInt("callback")); list.add(doc); } return list; } catch (SQLException e) { // TODO: handle exception e.printStackTrace(); } finally { close(rSet, preparedStatement, connection); } return null; } public static boolean setCallOver(Doc doc) { Connection con=null; PreparedStatement pstmt=null; try { con=getConn(); String sql="update doc_list set callback = ? where id = ?"; pstmt=con.prepareStatement(sql); pstmt.setInt(1, 0); pstmt.setInt(2, doc.getId()); pstmt.executeUpdate(); return true; } catch(SQLException e) { e.printStackTrace(); } finally { close(pstmt, con); } return false; } public static void main(String[] args) { //getConnection(); } }
entity包:
Users.java
package entity; public class Users { private int id; private String username; private String password; private int permissionId; private int status; private String job; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public int getPermissionId() { return permissionId; } public void setPermissionId(int permissionId) { this.permissionId = permissionId; } public int getStatus() { return status; } public void setStatus(int status) { this.status = status; } public String getJob() { return job; } public void setJob(String job) { this.job = job; } }
Permission.java
package entity; public class Permission { private int id; private int permission; public int getId() { return id; } public void setId(int id) { this.id = id; } public int getPermission() { return permission; } public void setPermission(int permission) { this.permission = permission; } }
Doc.java
package entity; public class Doc { private int id; private String tipplace; private String ftipplace; private int deletestatus; private int callback; public int getCallback() { return callback; } public void setCallback(int callback) { this.callback = callback; } public int getDeletestatus() { return deletestatus; } public void setDeletestatus(int deletestatus) { this.deletestatus = deletestatus; } public String getFtipplace() { return ftipplace; } public void setFtipplace(String ftipplace) { this.ftipplace = ftipplace; } public String getTipplace() { return tipplace; } public void setTipplace(String tipplace) { this.tipplace = tipplace; } public int getId() { return id; } public void setId(int id) { this.id = id; } private String title; private String owner; private String time; private String receiver; private int status; private int result; private String place; public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getOwner() { return owner; } public void setOwner(String owner) { this.owner = owner; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public String getReceiver() { return receiver; } public void setReceiver(String receiver) { this.receiver = receiver; } public int getStatus() { return status; } public void setStatus(int status) { this.status = status; } public int getResult() { return result; } public void setResult(int result) { this.result = result; } public String getPlace() { return place; } public void setPlace(String place) { this.place = place; } }
servlet包:
package servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Doc; import util.DBUtil; /** * Servlet implementation class CallBackOver */ @WebServlet("/CallBackOver") public class CallBackOver extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public CallBackOver() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.getWriter().append("Served at: ").append(request.getContextPath()); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //doGet(request, response); int id=Integer.parseInt(request.getParameter("id")); Doc doc=new Doc(); doc.setId(id); if(DBUtil.setCallOver(doc)) response.getWriter().write("yes"); else response.getWriter().write("no"); } }
package servlet; import java.io.IOException; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import util.DBUtil; import entity.Doc; /** * Servlet implementation class checkDoc */ @WebServlet("/checkDoc") public class checkDoc extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ /* public checkDoc() { super(); // TODO Auto-generated constructor stub } */ /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getWriter().append("Served at: ").append(request.getContextPath()); String type=request.getParameter("type"); ArrayList<Doc> list=DBUtil.getCheckedorNot(type); request.setAttribute("list", list); request.getRequestDispatcher("checkdoc.jsp").forward(request, response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }
package servlet; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Doc; import util.DBUtil; /** * Servlet implementation class checked_change */ @WebServlet("/checked_change") public class checked_change extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public checked_change() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.getWriter().append("Served at: ").append(request.getContextPath()); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //doGet(request, response); int id=Integer.parseInt(request.getParameter("id")); int result=Integer.parseInt(request.getParameter("result")); String tip=request.getParameter("tip"); Date date = new Date(); SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); String time=dateFormat.format(date).toString(); String path="C:\Users\Lenovo\eclipse-workspace\Gong\WebContent\tip"+id+"_"+time+"_tip.txt"; File file = new File(path); FileOutputStream fileOutputStream; int status; if(result==0) status=3; else status=2; Doc doc=new Doc(); doc.setId(id); doc.setResult(result); doc.setStatus(status); doc.setReceiver("办公室"); doc.setTipplace(path); if(DBUtil.checked_change(doc)) { try { fileOutputStream = new FileOutputStream(file); try { fileOutputStream.write((tip).getBytes()); fileOutputStream.close(); response.getWriter().write("yes"); } catch (IOException e) { // TODO 自动生成的 catch 块 response.getWriter().write("no"); e.printStackTrace(); } } catch (FileNotFoundException e) { // TODO 自动生成的 catch 块 response.getWriter().write("no"); e.printStackTrace(); } } else response.getWriter().write("no"); } }
package servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Doc; import util.DBUtil; /** * Servlet implementation class deleteDoc */ @WebServlet("/deleteDoc") public class deleteDoc extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public deleteDoc() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.getWriter().append("Served at: ").append(request.getContextPath()); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //doGet(request, response); int id=Integer.parseInt(request.getParameter("id")); Doc doc=new Doc(); doc.setId(id); doc.setDeletestatus(1); if(DBUtil.deleteDoc(doc)) response.getWriter().write("yes"); else response.getWriter().write("no"); } }
package servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Doc; import util.DBUtil; /** * Servlet implementation class doCheck */ @WebServlet("/doCheck") public class doCheck extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ /* public doCheck() { super(); // TODO Auto-generated constructor stub }*/ /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getWriter().append("Served at: ").append(request.getContextPath()); String id=request.getParameter("id"); Doc d=new Doc(); d.setId(Integer.parseInt(id)); Doc doc=DBUtil.getDocById(d); request.setAttribute("doc", doc); System.out.println(doc.getId()); request.getRequestDispatcher("writecheck.jsp").forward(request, response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }
package servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Doc; import util.DBUtil; /** * Servlet implementation class dofCheck */ @WebServlet("/dofCheck") public class dofCheck extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public dofCheck() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getWriter().append("Served at: ").append(request.getContextPath()); String id=request.getParameter("id"); Doc d=new Doc(); d.setId(Integer.parseInt(id)); Doc doc=DBUtil.getDocById(d); request.setAttribute("doc", doc); System.out.println(doc.getId()); request.getRequestDispatcher("writefcheck.jsp").forward(request, response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }
package servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Doc; import util.DBUtil; /** * Servlet implementation class doReceived */ @WebServlet("/doReceived") public class doReceived extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public doReceived() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.getWriter().append("Served at: ").append(request.getContextPath()); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //doGet(request, response); int id=Integer.parseInt(request.getParameter("id")); System.out.println(id); Doc doc=new Doc(); doc.setId(id); if(DBUtil.ReceiveDoc(doc)) response.getWriter().write("yes"); else response.getWriter().write("no"); } }
package servlet; import java.io.IOException; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Permission; import entity.Users; import util.DBUtil; /** * Servlet implementation class editPermission */ @WebServlet("/editPermission") public class editPermission extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public editPermission() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getWriter().append("Served at: ").append(request.getContextPath()); int id=Integer.parseInt(request.getParameter("id")); Users user=new Users(); user.setId(id); Users newuser=DBUtil.getUserById(user); Permission permission=new Permission(); permission.setId(newuser.getPermissionId()); ArrayList<Permission> list=DBUtil.getPermission(permission); request.setAttribute("list", list); request.getRequestDispatcher("editPermission.jsp").forward(request, response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }
package servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Users; import util.DBUtil; /** * Servlet implementation class editUserInfo */ @WebServlet("/editUserInfo") public class editUserInfo extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public editUserInfo() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getWriter().append("Served at: ").append(request.getContextPath()); int id=Integer.parseInt(request.getParameter("id")); Users user=new Users(); user.setId(id); Users newuser=DBUtil.getUserById(user); request.setAttribute("user", newuser); request.getRequestDispatcher("editUser.jsp").forward(request, response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }
package servlet; import java.io.IOException; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Doc; import util.DBUtil; /** * Servlet implementation class fcheckDoc */ @WebServlet("/fcheckDoc") public class fcheckDoc extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public fcheckDoc() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getWriter().append("Served at: ").append(request.getContextPath()); String type=request.getParameter("type"); ArrayList<Doc> list=DBUtil.getFcheckedorNot(type); request.setAttribute("list", list); request.getRequestDispatcher("fcheckdoc.jsp").forward(request, response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }
fchecked_change
package servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Doc; import util.DBUtil; /** * Servlet implementation class formatDoc */ @WebServlet("/formatDoc") public class formatDoc extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public formatDoc() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.getWriter().append("Served at: ").append(request.getContextPath()); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //doGet(request, response); int id=Integer.parseInt(request.getParameter("id")); int status=Integer.parseInt(request.getParameter("status")); if(status==-1) { status=0; Doc doc=new Doc(); doc.setId(id); doc.setStatus(status); if(DBUtil.formatDoc(doc)) response.getWriter().write("yes"); else response.getWriter().write("no"); } else response.getWriter().write("no"); } }
package servlet; import java.io.IOException; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Users; import util.DBUtil; /** * Servlet implementation class getAllUser */ @WebServlet("/getAllUser") public class getAllUser extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public getAllUser() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getWriter().append("Served at: ").append(request.getContextPath()); ArrayList<Users> list=DBUtil.getAllUser(); request.setAttribute("list", list); request.getRequestDispatcher("Usermanage.jsp").forward(request, response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }
package servlet; import java.io.IOException; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Doc; import util.DBUtil; /** * Servlet implementation class getDoc */ @WebServlet("/getDoc") public class getDoc extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ /* public getDoc() { super(); // TODO Auto-generated constructor stub } */ /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getWriter().append("Served at: ").append(request.getContextPath()); doPost(request, response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //doGet(request, response); String type=request.getParameter("type"); ArrayList<Doc> list=DBUtil.getDoces(type); request.setAttribute("list", list); request.getRequestDispatcher("senddoc.jsp").forward(request, response); } }
package servlet; import java.io.IOException; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Doc; import entity.Users; import util.DBUtil; /** * Servlet implementation class getReceivedorNot */ @WebServlet("/getReceivedorNot") public class getReceivedorNot extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public getReceivedorNot() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getWriter().append("Served at: ").append(request.getContextPath()); String username=request.getParameter("user"); String type=request.getParameter("type"); Users user=new Users(); user.setUsername(username); System.out.println(user.getUsername()); ArrayList<Doc> list=DBUtil.getReceivedByUser(type, user); request.setAttribute("list", list); request.getRequestDispatcher("receive.jsp").forward(request, response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }
package servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Users; import util.DBUtil; /** * Servlet implementation class login_do */ @WebServlet("/login_do") public class login_do extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public login_do() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.getWriter().append("Served at: ").append(request.getContextPath()); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //doGet(request, response); String username=request.getParameter("username"); String password=request.getParameter("password"); Users user=new Users(); user.setUsername(username); user.setPassword(password); if(DBUtil.log_isExist(user)) { Cookie cookie=new Cookie("username", username); cookie.setPath("/"); //设置存活时间 cookie.setMaxAge(60*60*24); response.addCookie(cookie); Users users=DBUtil.getUserByUsername(user); int pid=users.getPermissionId(); Cookie cookie2=new Cookie("pid", Integer.toString(pid)); cookie2.setPath("/"); cookie2.setMaxAge(60*60*24); response.addCookie(cookie2); response.getWriter().write("yes"); } else { response.getWriter().write("no"); } } }
package servlet; import java.io.IOException; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Doc; import util.DBUtil; /** * Servlet implementation class queryByTime */ @WebServlet("/queryByTime") public class queryByTime extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public queryByTime() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.getWriter().append("Served at: ").append(request.getContextPath()); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //doGet(request, response); String begin=request.getParameter("begin"); String end=request.getParameter("end"); System.out.println(begin+" "+end); Doc doc1=new Doc(); Doc doc2=new Doc(); doc1.setTime(begin); doc2.setTime(end); ArrayList<Doc> list=DBUtil.getDocByTime(doc1, doc2); response.setContentType("text/html;charset=utf-8"); response.getWriter().print(com.alibaba.fastjson.JSONArray.toJSON(list).toString()); } }
package servlet; import java.io.IOException; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Doc; import util.DBUtil; /** * Servlet implementation class queryDoc */ @WebServlet("/queryDoc") public class queryDoc extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public queryDoc() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getWriter().append("Served at: ").append(request.getContextPath()); request.setCharacterEncoding("utf-8"); String type=request.getParameter("type"); if(type.equals("all")) { ArrayList<Doc> list=DBUtil.getDoces("all"); request.setAttribute("list", list); request.getRequestDispatcher("querydoc.jsp").forward(request, response); } else { String value=request.getParameter("value"); System.out.println(value); ArrayList<Doc> list=DBUtil.getDocesByCase(type,value); request.setAttribute("list", list); request.getRequestDispatcher("querydoc.jsp").forward(request, response); } } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }
package servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import util.DBUtil; /** * Servlet implementation class sendDoc */ @WebServlet("/sendDoc") public class sendDoc extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ /* public sendDoc() { super(); // TODO Auto-generated constructor stub } */ /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.getWriter().append("Served at: ").append(request.getContextPath()); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //doGet(request, response); int id=Integer.parseInt(request.getParameter("id")); if(DBUtil.sendDoc(id)) { response.getWriter().write("yes"); } else { response.getWriter().write("no"); } } }
package servlet; import java.io.IOException; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class showAll */ import entity.Doc; import util.DBUtil; @WebServlet("/showAll") public class showAll extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public showAll() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getWriter().append("Served at: ").append(request.getContextPath()); ArrayList<Doc> list=DBUtil.getAllDoc(); request.setAttribute("list", list); request.getRequestDispatcher("showall.jsp").forward(request, response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }
package servlet; import java.io.IOException; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Doc; import util.DBUtil; /** * Servlet implementation class showCall */ @WebServlet("/showCall") public class showCall extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public showCall() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getWriter().append("Served at: ").append(request.getContextPath()); ArrayList<Doc> list=DBUtil.getCall(); request.setAttribute("list", list); request.getRequestDispatcher("showcall.jsp").forward(request, response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }
package servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Doc; import util.DBUtil; /** * Servlet implementation class showSug */ @WebServlet("/showSug") public class showSug extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public showSug() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getWriter().append("Served at: ").append(request.getContextPath()); int id=Integer.parseInt(request.getParameter("id")); Doc doc=new Doc(); doc.setId(id); Doc newdoc=DBUtil.getDocById(doc); request.setAttribute("doc", newdoc); request.getRequestDispatcher("showresult.jsp").forward(request, response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }
package servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Users; import util.DBUtil; /** * Servlet implementation class updateSelf */ @WebServlet("/updateSelf") public class updateSelf extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public updateSelf() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //response.getWriter().append("Served at: ").append(request.getContextPath()); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //doGet(request, response); String username=request.getParameter("username"); String password=request.getParameter("password"); Users user=new Users(); user.setUsername(username); user.setPassword(password); if(DBUtil.updatePwd(user)) response.getWriter().write("yes"); else response.getWriter().write("no"); } }
package servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Users; import util.DBUtil; /** * Servlet implementation class updateUserInfo */ @WebServlet("/updateUserInfo") public class updateUserInfo extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public updateUserInfo() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.getWriter().append("Served at: ").append(request.getContextPath()); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //doGet(request, response); int id=Integer.parseInt(request.getParameter("id")); String username=request.getParameter("username"); String password=request.getParameter("password"); String job=request.getParameter("job"); Users user=new Users(); user.setId(id); user.setUsername(username); user.setPassword(password); user.setJob(job); if(DBUtil.update_user(user)) response.getWriter().write("yes"); else response.getWriter().write("no"); } }
package servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Users; import util.DBUtil; /** * Servlet implementation class users_do */ @WebServlet("/users_do") public class users_do extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public users_do() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.getWriter().append("Served at: ").append(request.getContextPath()); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //doGet(request, response); String method=request.getParameter("method"); int id=Integer.parseInt(request.getParameter("id")); Users user=new Users(); user.setId(id); if(method.equals("delete")) { if(DBUtil.delete_user(user)) response.getWriter().write("yes"); else response.getWriter().write("no"); } else if(method.equals("pause")) { int status=Integer.parseInt(request.getParameter("status")); if(status==0) status=1; else { status=0; } user.setStatus(status); if(DBUtil.update_userstatus(user)) response.getWriter().write(status); else response.getWriter().write("no"); } else { response.sendRedirect("editUserInfo?id="+id); } } }
package servlet; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Doc; import util.DBUtil; /** * Servlet implementation class writedoc_do */ @WebServlet("/writedoc_do") public class writedoc_do extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public writedoc_do() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.getWriter().append("Served at: ").append(request.getContextPath()); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //doGet(request, response); String text=request.getParameter("text"); String user=request.getParameter("user"); String title=request.getParameter("title"); System.out.println(text); Date date = new Date(); SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); String time=dateFormat.format(date).toString(); String path="C:\Users\Lenovo\eclipse-workspace\Gong\WebContent\text\"+title+"_"+user+"_"+time.split(":| ")[0]+time.split(":| ")[1]+time.split(":| ")[2]+time.split(":| ")[3]+".txt"; System.out.println(path); File file = new File(path); FileOutputStream fileOutputStream; Doc doc=new Doc(); doc.setTitle(title); doc.setOwner(user); doc.setReceiver("办公室"); doc.setTime(time); doc.setStatus(-1); doc.setResult(0); doc.setPlace(path); if(DBUtil.add_doc(doc)) { try { fileOutputStream = new FileOutputStream(file); try { fileOutputStream.write((text).getBytes()); fileOutputStream.close(); response.getWriter().write("yes"); } catch (IOException e) { // TODO 自动生成的 catch 块 response.getWriter().write("no"); e.printStackTrace(); } } catch (FileNotFoundException e) { // TODO 自动生成的 catch 块 response.getWriter().write("no"); e.printStackTrace(); } } else { response.getWriter().write("no"); } } }