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();
}
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);
}
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);
}
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);
}
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);
}
}
Aggregations