/** * This method is invoked when an attribute is removed from the ServletContext object * * @param se Description of the Parameter */ public void attributeRemoved(HttpSessionBindingEvent se) { ServletContext context = se.getSession().getServletContext(); try { if (se.getName().equals("User")) { UserBean thisUser = (UserBean) se.getValue(); if (thisUser != null) { // Internal SessionManager int userId = thisUser.getActualUserId(); if (userId > -2) { // If context reloaded, then SystemStatus is null, but user is valid Hashtable systems = (Hashtable) context.getAttribute("SystemStatus"); if (systems != null) { SystemStatus systemStatus = (SystemStatus) systems.get(thisUser.getConnectionElement().getUrl()); if (systemStatus != null) { // Remove the user from the session if it already is there SessionManager thisManager = systemStatus.getSessionManager(); if (thisManager != null) { UserSession thisSession = thisManager.getUserSession(userId); if (thisSession != null && thisSession.getId().equals(thisUser.getSessionId())) { if (System.getProperty("DEBUG") != null) { System.out.println( "ContextSessionListener-> Session for user " + userId + " ended"); } thisManager.removeUser(userId); if (System.getProperty("DEBUG") != null) { System.out.println( "ContextSessionListener-> User removed from valid user list"); } } } // Website Tracker Tracker tracker = systemStatus.getTracker(); tracker.remove(thisUser.getSessionId()); } } } } } } catch (Exception e) { e.printStackTrace(System.out); System.out.println("ContextSessionListener-> attributeRemoved Error: " + e.toString()); } }
/** * The doPost method of the servlet. <br> * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); out.println("<HTML>"); out.println(" <HEAD><TITLE>Database Init</TITLE></HEAD>"); out.println(" <BODY>"); // request.setCharacterEncoding("UTF-8"); // response.setCharacterEncoding("GBK"); // request.setCharacterEncoding("GBK"); response.setCharacterEncoding("GBK"); response.setContentType("text/html"); request.setCharacterEncoding("GBK"); int startIndex = 0; int endIndex = 0; int programNum = 0; int clearflag = 1; // 不清除节目映射表信息 try { clearflag = Integer.parseInt(request.getParameter("cleardb")); } catch (Exception ex) { } // int indexNum = Integer.parseInt(request.getParameter("IndexNum")); try { // 开始通道号 startIndex = Integer.parseInt(request.getParameter("StartIndex")); } catch (Exception ex) { } try { // 结束通道号 endIndex = Integer.parseInt(request.getParameter("EndIndex")); } catch (Exception ex) { } try { programNum = Integer.parseInt(request.getParameter("ProgramNum")); } catch (Exception ex) { } out.println("<br> StartIndex: " + startIndex); out.println("<br> EndIndex: " + endIndex); out.println("<br> ProgramNum: " + programNum); try { // 清除原始节目映射表 if (clearflag == 0) { out.println( "<br>recover channel from [" + startIndex + "-----" + endIndex + " ]from channelremapping"); delChannelIndex(); // 插入节目映射表 initChannelRemappingIndex(startIndex, endIndex + 1, programNum); } if (clearflag == 1) { out.println( "<br>insert into channelremapping from [" + startIndex + "-----" + endIndex + "] program info"); // 插入节目映射表 initChannelRemappingIndex(startIndex, endIndex + 1, programNum); } // 删除某通道节目映射 if (clearflag == 2 && startIndex == endIndex) { out.println("<br>delete channel-[" + startIndex + "] from channelremapping"); delChannelIndex(startIndex); } else { if (clearflag == 2) { out.println("<br>Attention!!! first channel must equal last channel"); } } } catch (Exception e) { // TODO Auto-generated catch block // e.printStackTrace(); } try { List<SetAutoRecordChannelVO> AutoRecordlistSMGNew = SystemStatus.selectChannelRemappingInfo(1); out.println("<FORM method=\"POST\" name=\"form1\" action=\"./servlet/controlAlarm\">"); out.println("<table border=1 cellspacing=1 >"); out.println("<tr>"); out.println("<td>DevIndex</td>"); out.println("<td>ChannelIndex</td>"); out.println("<td>Freq</td>"); out.println("<td>ServiceID</td>"); out.println("<td>HDFlag</td>"); out.println("</tr>"); for (int i = 0; i < AutoRecordlistSMGNew.size(); i++) { SetAutoRecordChannelVO vo = (SetAutoRecordChannelVO) AutoRecordlistSMGNew.get(i); out.println("<tr>"); out.println("<td> " + vo.getDevIndex() + " </td>"); out.println("<td> " + vo.getIndex() + " </td>"); out.println("<td> " + vo.getFreq() + "</td>"); out.println("<td> " + vo.getServiceID() + " </td>"); out.println("<td> " + vo.getHDFlag() + "</td>"); out.println("</tr>"); } out.println(" </table>"); out.println(" </FORM>"); } catch (DaoException e) { e.printStackTrace(); } out.println(" </BODY>"); out.println("</HTML>"); out.flush(); out.close(); }