public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse arg1)
      throws Exception {

    Map<String, Object> model = new HashMap<String, Object>();
    try {
      List<TServerInfo> serverinfo = TServerInfoDao.findAll();
      List<TSvrmodMap> servermodule = TSvrmodMapDao.findAll();
      Map<String, Object> map = new HashMap<String, Object>();
      TModuleInfoInit moduleInfo = null;
      // Map<Long,Map<Long,List<TModuleInfoInit>>> moduleInfos = new
      // HashMap<Long,Map<Long,List<TModuleInfoInit>>>();
      /*for (TSvrmodMap dto: servermodule) {
      	List list;
      	if (map.containsKey(dto.getNmsid()+"")){
      		list = (List) map.get(dto.getNmsid()+"");
      	}else{
      		list = new ArrayList();
      	}
      	list.add(dto);
      	map.put(dto.getNmsid()+"", list);

      }*/

      Map<Long, Object> moduleInfos = new HashMap<Long, Object>();
      List<TModuleInfoInit> infos = new ArrayList<TModuleInfoInit>();
      if (servermodule != null && servermodule.size() > 0) {
        for (int m = 0; m < servermodule.size(); m++) {
          long nmsid = servermodule.get(m).getNmsid();
          if (moduleInfos.containsKey(nmsid) == false) {
            //	System.out.println("nmsid is----"+servermodule.get(m).getNmsid());
            List<TSvrmodMap> serMod = TSvrmodMapDao.findWhereNmsidEquals(nmsid);
            //	System.out.println("serMod is---"+serMod);
            if (serMod != null && serMod.size() > 0) {
              for (int i = 0; i < serMod.size(); i++) {
                long modid = serMod.get(i).getModid();
                //	System.out.println("modid is---"+serMod.get(i).getModid());
                moduleInfo = TModuleInfoInitDao.findByPrimaryKey(modid);

                if (moduleInfos.containsKey(nmsid)) {
                  infos = (List<TModuleInfoInit>) moduleInfos.get(nmsid);
                } else {
                  infos = new ArrayList<TModuleInfoInit>();
                }
                infos.add(moduleInfo);
                //	System.out.println("infos is----"+infos);
                moduleInfos.put(nmsid, infos);
                //	System.out.println("modInfos is---"+moduleInfos);
              }
            }
          }
        }
      }

      model.put("server", serverinfo);
      model.put("servermodule", servermodule);
      model.put("moduleInfos", moduleInfos);
      // model.put("map", map);
      System.out.println(model);
    } catch (Exception e) {
      Log4jInit.ncsLog.error(this.getClass().getName() + " Error occured:\n" + e.getMessage());
      e.printStackTrace();
    }
    return new ModelAndView(getPageView(), "model", model);
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.springframework.web.servlet.mvc.Controller#handleRequest(javax.servlet
   * .http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    message = "";
    Map<String, Object> model = new HashMap<String, Object>();
    try {
      message = request.getParameter("message");
      String mpidstr = request.getParameter("mpid");
      long mpid = Long.parseLong(mpidstr);
      TPolicyBase policyBase = TPolicyBaseDao.findByPrimaryKey(mpid);
      model.put("policyBase", policyBase);
      if (policyBase.getPtvid() > 0) {
        model.put("ptvid", policyBase.getPtvid());
      }

      String mpname = request.getParameter("mpname");

      String category = request.getParameter("cate");
      String displayOption = request.getParameter("listSeled");
      String selectedEveType = request.getParameter("listeve_type");
      // System.out.println("&&&&&&&&&&%%%%%%%%%%%%%%selEvetype=" +
      // selectedEveType);
      String mode = request.getParameter("mode");

      if (mode == null || mode.equals("")) mode = "SNMP";

      // get manufacture list
      String manufacture = request.getParameter("manufselect");
      // System.out.println("Manufacture selection is: " + manufacture);
      Map<Integer, List<DspSyslogEvents>> unselectedSyslog =
          new HashMap<Integer, List<DspSyslogEvents>>();
      Map<String, Map> DspSyslogMap = new TreeMap<String, Map>();
      List<TManufacturerInfoInit> tmflist = TManufacturerInfoInitDao.findAll();
      SortList<TManufacturerInfoInit> sortmanu = new SortList<TManufacturerInfoInit>();
      sortmanu.Sort(tmflist, "getMrname", null);
      model.put("mflist", tmflist);

      List<PolDetailDsp> details = new ArrayList<PolDetailDsp>();
      Map<String, Object> detailMap = new HashMap<String, Object>();
      Map<Integer, Object> syslogdetailMap = new HashMap<Integer, Object>();
      // List<PolicySyslog> syslogDetails = new ArrayList<PolicySyslog>();
      List<DspEventsFromPolicySyslog> eventsSyslogDetails =
          new ArrayList<DspEventsFromPolicySyslog>();
      Map<String, Object> eventsDictionary = new HashMap<String, Object>();
      if (!mode.equalsIgnoreCase("syslog")) {
        details = PolDetailDspDao.findByMpid(mpid);

        for (PolDetailDsp dto : details) {
          String key = dto.getMname();
          key = (key == null) ? "" : key;
          List<PolDetailDsp> templst = null;
          if (detailMap.containsKey(key)) {
            templst = (List<PolDetailDsp>) detailMap.get(key);
          } else {
            templst = new ArrayList<PolDetailDsp>();
          }
          templst.add(dto);
          detailMap.put(key, templst);
        }
        // System.out.println("detailMap="+detailMap);
        details = (List<PolDetailDsp>) detailMap.get(mode.toLowerCase());
      } else { // syslog policies
        // syslogDetails =
        // policySyslogDao.findWhereManufactureAndMpidEquals(manufacture,mpid);
        // //
        // System.out.println("%%%%%%%%%%%%Get ppppolicy syslog by selected manufacture size="
        // + syslogDetails.size()+ "\n\tcontent:\n" + syslogDetails);
        // for(PolicySyslog dto: syslogDetails){
        // int key = Integer.parseInt(String.valueOf(dto.getEventtype()));
        // List<PolicySyslog> templst = null;
        // if(syslogdetailMap.containsKey(key)){
        // templst = (List<PolicySyslog>)syslogdetailMap.get(key);
        // }else{
        // templst = new ArrayList<PolicySyslog>();
        // }
        // templst.add(dto);
        // syslogdetailMap.put(key, templst);
        //
        // }

        try {
          eventsSyslogDetails =
              DspEventsFromPolicySyslogDao.findDspEventsByManufactureAndMpid(manufacture, mpid);
          SortList<DspEventsFromPolicySyslog> sortpol = new SortList<DspEventsFromPolicySyslog>();
          sortpol.Sort(eventsSyslogDetails, "getEvents", null);
        } catch (Exception e) {
          e.printStackTrace();
        }

        for (DspEventsFromPolicySyslog dto : eventsSyslogDetails) {
          int key = Integer.parseInt(String.valueOf(dto.getEventtype()));
          List<DspEventsFromPolicySyslog> templst = null;
          if (syslogdetailMap.containsKey(key)) {
            templst = (List<DspEventsFromPolicySyslog>) syslogdetailMap.get(key);
          } else {
            templst = new ArrayList<DspEventsFromPolicySyslog>();
          }
          templst.add(dto);
          syslogdetailMap.put(key, templst);
        }
        // List<DspSyslogEvents> occupiedSysloglst =
        // dspSyslogEventsDao.listOccupiedSyslogEvents();
        // for(DspSyslogEvents dto :occupiedSysloglst){
        // String kmark = dto.getMark();
        // String kmf = dto.getManufacture();
        // String keymarkmf = kmark +"_"+kmf;
        // String vEvents = dto.getEvents();
        // eventsDictionary.put(keymarkmf, vEvents);
        // }
        // System.out.println("syslogdetailMap="+syslogdetailMap);
      }

      List<TModuleInfoInit> module = TModuleInfoInitDao.findAll();

      List<TEventTypeInit> unselected = null; /* */
      List<TEventTypeInit> snmplst = null; /* */
      if (category.equals("1")) { // cate=1 as DEVECE policy
        snmplst = TEventTypeInitDao.listForDeviceSnmp(mpid);
      } else if (category.equals("4")) // treated as PORT policy
      {
        snmplst = TEventTypeInitDao.listForPortSnmp(mpid);
      } else if (category.equals("9")) // treated as PreDefMib policy
      {
        snmplst = TEventTypeInitDao.listForPreDefMibSnmp(mpid);
      }
      List<TEventTypeInit> icmplst = null; /* */
      if (category.equals("1")) { // cate=1 as DEVECE policy
        icmplst = TEventTypeInitDao.listForDeviceIcmp(mpid);
      } else if (category.equals("4")) // treated as PORT policy
      {
        icmplst = TEventTypeInitDao.listForPortIcmp(mpid);
      } else if (category.equals("9")) // treated as PreDefMib policy
      {
        icmplst = TEventTypeInitDao.listForPortIcmp(mpid);
      }

      if (mode.equalsIgnoreCase("icmp")) {
        unselected = icmplst;
      } else if (mode.equalsIgnoreCase("snmp")) {
        unselected = snmplst;
      }
      if (mode.equalsIgnoreCase("syslog")) {
        model.put("details", syslogdetailMap);
        model.put("unselected", unselectedSyslog);
      } else {
        if (details != null) {
          for (PolDetailDsp pdd : details) {
            TPolicyDetailsWithRule policyDetailsWithRule =
                this.policyDetailsWithRuleDao.findByEveidAndModid(
                    pdd.getPtvid(), pdd.getEveid(), pdd.getModid());
            pdd.setPolicyDetailsWithRule(policyDetailsWithRule);
          }
        }
        model.put("details", details);
        model.put("unselected", unselected);
      }
      model.put("mpid", mpidstr);
      model.put("mpname", mpname);
      model.put("displayOption", displayOption);
      model.put("selectedEveType", selectedEveType);
      model.put("cate", category);
      model.put("mode", mode);
      model.put("eventType", getEventTypeMap());
      model.put("syslog", DspSyslogMap);
      model.put("pmpmanu", manufacture);
    } catch (Exception e) {
      Log4jInit.ncsLog.error(this.getClass().getName() + " Error occured:\n" + e.getMessage());
      e.printStackTrace();
    }

    return new ModelAndView(getPageView(), "model", model);
  }