Search in sources :

Example 41 with User

use of com.zyf.bean.User in project HeartWatchdogJsp by Viczyf.

the class Info24Servlet method select_con_list.

public void select_con_list(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    Info24Dao info24Dao = new Info24Dao();
    HttpSession session = request.getSession();
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    // List infoList = info24Dao.queryInfo24(uid);
    // JsonArray array = new JsonArray();
    int id = MyTools.strToint(request.getParameter("id"));
    Info24 single = info24Dao.queryInfoSingle(id, uid);
    JsonObject ob = new JsonObject();
    String conclusion = "";
    String addr = single.getConclusionaddr();
    String file = request.getSession().getServletContext().getRealPath("/") + "24holter/conclusion/" + addr;
    try {
        BufferedReader rd = new BufferedReader(new FileReader(file));
        String s = rd.readLine();
        while (null != s) {
            conclusion += s;
            s = rd.readLine();
        }
        rd.close();
    // System.out.println(str);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    conclusion = "[" + conclusion + "]";
    ob.addProperty("con", conclusion);
    // array.add(ob);
    PrintWriter out = response.getWriter();
    out.print(ob);
    out.flush();
    out.close();
}
Also used : Info24Dao(com.zyf.dao.Info24Dao) User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) JsonObject(com.google.gson.JsonObject) Info24(com.zyf.bean.Info24)

Example 42 with User

use of com.zyf.bean.User in project HeartWatchdogJsp by Viczyf.

the class InfoServlet method singleInfo.

public void singleInfo(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    InfoDao infodao = new InfoDao();
    int id = MyTools.strToint(request.getParameter("id"));
    HttpSession session = request.getSession();
    // 获取用户对象
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    Info infosingle = infodao.queryInfoSingle(id, uid);
    request.setAttribute("infosingle", infosingle);
    RequestDispatcher rd = request.getRequestDispatcher("infosingle.jsp");
    rd.forward(request, response);
}
Also used : User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) InfoDao(com.zyf.dao.InfoDao) Info(com.zyf.bean.Info) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 43 with User

use of com.zyf.bean.User in project HeartWatchdogJsp by Viczyf.

the class InfoServlet method select_time_info.

public void select_time_info(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    InfoDao infodao = new InfoDao();
    String startdate = request.getParameter("startdate");
    String enddate = request.getParameter("enddate");
    HttpSession session = request.getSession();
    // 获取用户对象
    User user = (User) session.getAttribute("user");
    int id = user.getUid();
    List infoList = infodao.queryTimeInfo(id, startdate, enddate);
    JsonArray array = new JsonArray();
    for (int i = 0; i < infoList.size(); i++) {
        Info single = (Info) infoList.get(i);
        JsonObject ob = new JsonObject();
        ob.addProperty("id", i + 1);
        ob.addProperty("date", single.getDate());
        ob.addProperty("read", "<a href=\"InfoServlet?action=single&id=" + single.getId() + " \"target=\"_blank\">查看记录</a>");
        ob.addProperty("read1", "<a href=\"InfoServlet?action=singlepot&id=" + single.getId() + " \"target=\"_blank\">查看记录</a>");
        ob.addProperty("del", "<a href=\"InfoServlet?action=delete&id=" + single.getId() + "\">删除记录</a>");
        array.add(ob);
    }
    PrintWriter out = response.getWriter();
    out.print(array);
    System.out.println(array);
}
Also used : JsonArray(com.google.gson.JsonArray) User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) InfoDao(com.zyf.dao.InfoDao) JsonObject(com.google.gson.JsonObject) List(java.util.List) Info(com.zyf.bean.Info) PrintWriter(java.io.PrintWriter)

Example 44 with User

use of com.zyf.bean.User in project HeartWatchdogJsp by Viczyf.

the class InfoServlet method deleteInfo.

public void deleteInfo(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String message = "";
    String forward = "";
    String href = "";
    InfoDao infodao = new InfoDao();
    int id = MyTools.strToint(request.getParameter("id"));
    Info info = new Info();
    info.setId(id);
    HttpSession session = request.getSession();
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    boolean mark = infodao.delInfo(info, uid);
    if (mark) {
        message = message + "<li>删除记录成功!</li>";
        forward = "tishi.jsp";
        href = href + "infotime.jsp";
    } else {
        message = message + "<li>删除记录失败!</li>";
        forward = "tishi.jsp";
        href = href + "infotime.jsp";
    }
    request.setAttribute("message", message);
    request.setAttribute("href", href);
    RequestDispatcher rd = request.getRequestDispatcher(forward);
    rd.forward(request, response);
}
Also used : User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) InfoDao(com.zyf.dao.InfoDao) Info(com.zyf.bean.Info) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 45 with User

use of com.zyf.bean.User in project HeartWatchdogJsp by Viczyf.

the class LoginFilter method doFilter.

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    // 获得在下面代码中要用的request,response,session对象
    HttpServletRequest servletRequest = (HttpServletRequest) request;
    HttpServletResponse servletResponse = (HttpServletResponse) response;
    HttpSession session = servletRequest.getSession();
    // 获得用户请求的URI
    String path = servletRequest.getRequestURI();
    // System.out.println(path);
    List<String> NoFilter_Pages = new ArrayList<String>();
    NoFilter_Pages.add("register.jsp");
    NoFilter_Pages.add("enterimage.jsp");
    // 从session里取员工工号信息
    User user = (User) session.getAttribute("user");
    /*创建类Constants.java,里面写的是无需过滤的页面*/
    for (int i = 0; i < NoFilter_Pages.size(); i++) {
        if (path.contains(NoFilter_Pages.get(i))) {
            chain.doFilter(servletRequest, servletResponse);
            return;
        }
    }
    // 登陆页面无需过滤
    if (path.indexOf("/login.jsp") > -1) {
        chain.doFilter(request, response);
        return;
    }
    // 判断如果没有取到员工信息,就跳转到登陆页面
    if (user == null) {
        // 跳转到登陆页面
        servletResponse.sendRedirect("/login.jsp");
    // servletRequest.getRequestDispatcher("login.jsp").forward(servletRequest, servletResponse);
    } else {
        // 已经登陆,继续此次请求
        // System.out.println("用户已经登录");
        chain.doFilter(request, response);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) ArrayList(java.util.ArrayList) HttpServletResponse(javax.servlet.http.HttpServletResponse)

Aggregations

User (com.zyf.bean.User)53 HttpSession (javax.servlet.http.HttpSession)51 RequestDispatcher (javax.servlet.RequestDispatcher)28 List (java.util.List)18 PrintWriter (java.io.PrintWriter)17 JsonObject (com.google.gson.JsonObject)12 JsonArray (com.google.gson.JsonArray)11 InfoDao (com.zyf.dao.InfoDao)9 Info (com.zyf.bean.Info)7 ExaminationDao (com.zyf.dao.ExaminationDao)7 Info24 (com.zyf.bean.Info24)6 Info24Dao (com.zyf.dao.Info24Dao)6 RelaDao (com.zyf.dao.RelaDao)6 UserDao (com.zyf.dao.UserDao)6 Examination (com.zyf.bean.Examination)5 MedicalhistoryDao (com.zyf.dao.MedicalhistoryDao)5 Medicalhistory (com.zyf.bean.Medicalhistory)4 Urine (com.zyf.bean.Urine)4 FileDao (com.zyf.dao.FileDao)4 UrineDao (com.zyf.dao.UrineDao)4