<%@	include	file = "EgMonitorTracker.jsp" %>
<%@ page import="com.egurkha.UserRegistry"%>
<%@ page import="com.egurkha.EgUserRole"%>
<%@  page import= "java.util.Vector"%>
<%@  page import= "java.util.Hashtable"%>
<%@	page import	= "java.util.HashMap"%>
<%@	page import	= "java.util.StringTokenizer"%>
<%@  page import= "com.eg.IniFile"%>
<%@ page import = "egurkha.reporter.ErUtils"%>
<%@  page import= "com.eg.EgInstallInfo" %>
<%@  page import= "java.net.URLEncoder" %>
<%@  page import="com.egurkha.monitor.EgCtxUserBean" %>
<%@ page import = "com.egurkha.monitor.VMDesktopBean"%>
<%@  page import="com.egurkha.monitor.EgDashBoardDAO" %>
<%@ page import = "com.eg.EgMappingInfo" %>
<%@  page import = "com.egurkha.User" %>
<%@  page import = "com.egurkha.UserRegistry" %>
<%@  page import = "com.egurkha.EgUserRole" %>
<%@  page import = "com.egurkha.ini.IniUI" %>
<%@  page import= "com.eg.EgDateInfo" %>
<%@  page import= "com.eg.EgTablesInfo" %>
<%@  page import= "com.eg.EgDbInfo" %>
<%@  page import= "com.eg.EgExternalInfo" %>
<%@  page import= "com.eg.EgSpecsInfo" %>
<%@  page import= "com.eg.EgAgentInfo" %>
<%@  page import= "com.eg.EgTesterInfo" %>
<%@ page import = "com.eg.EgMemInfo" %>
<%@page import = "com.eg.EgURLEncoder"%>
<%@  page import= "com.egurkha.util.DateUtil" %>
<%@ page import = "com.egurkha.monitor.EgServerDashBoardDAO"%>
<%@ page import = "com.egurkha.monitor.MonitorDAOFactory"%>
<%@ page import="net.sf.json.*"%>
<%@ page import="java.text.SimpleDateFormat"%> 
<%@  page import= "com.eg.EgFormatInfo" %>
<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<jsp:useBean id="dd" scope="page" class="com.egurkha.monitor.EgDiagnosisBean" />
<jsp:useBean id="trans" scope="page" class="egurkha.TransactionBean"/>
<%
		UserRegistry registry = UserRegistry.getInstance();
		User userObj = registry.getUser(session.getId());
		EgDbInfo MeasureDisplay=new EgDbInfo("manager");
		TreeMap linksMap = new TreeMap();
		List listData = new LinkedList();
		String uiFile11 = "eg_ui.ini";
		String s_iniFile_dir11 = EgInstallInfo.getInstallDir()+ "/manager/config/";
		IniFile egUI11 = new IniFile(s_iniFile_dir11 + uiFile11);
		String[] options = {"Any","Recent","1 hour", "3 hours", "6 hours", "9 hours", "12 hours","15 hours", "18 hours","21 hours","24 hours", "2 days", "3 days", "4 days", "5 days", "6 days","1 week","2 weeks","3 weeks","4 weeks","1 month","2 months"};           
		JSONObject gridObj=new JSONObject();
		JSONArray gridData = new JSONArray();
		JSONArray columnDetails = new JSONArray(); 
		JSONObject rootJson = new JSONObject();
		JSONObject screenLabels = new JSONObject();
		JSONArray  stateGenOpts = new JSONArray();
		JSONObject dateTime = new JSONObject();
		boolean flage_header=true;
		String  defaulttimelinevalue="";
		String s_timeline=request.getParameter("eg_timeline"); 
		String eg_tbound=request.getParameter("eg_tbound");  
		eg_tbound = (eg_tbound==null||eg_tbound.equalsIgnoreCase("null")||eg_tbound.trim().length()==0)?"":eg_tbound;
		String eg_stdate = request.getParameter("eg_stdate");
		String eg_enddate = request.getParameter("eg_enddate");
		String start_hr = request.getParameter("starthr");
		String end_hr = request.getParameter("endhr");
		String startmin_h = request.getParameter("startmin_h");
		startmin_h=(startmin_h==null || startmin_h.trim().length()==0 || startmin_h.equals("null"))?"00":startmin_h;
		String endmin_h = request.getParameter("endmin_h");
		endmin_h=(endmin_h==null || endmin_h.trim().length()==0|| endmin_h.equals("null"))?"59":endmin_h;
		String isFromLayers = request.getParameter("isFromLayers");
		boolean isFromLayersFlag = false;
		isFromLayersFlag = (isFromLayers==null||isFromLayers.equalsIgnoreCase("null")||isFromLayers.trim().length()==0)?false:true;
		String currentDateFormat = egUI11.getValue("CURRENT_DATE_FORMAT","selectedDateFormat");
		if(isFromLayersFlag)
		{
			gridObj.put("isFromLayers",isFromLayersFlag);
			String comFormat = "";
			String userFormat = u_ser.getUserDateFormat();
			if(eg_stdate!=null && !eg_stdate.equalsIgnoreCase("null") && eg_stdate.trim().length()>0)
			{
				if(DateUtil.isDate(eg_stdate,"MM/dd/yyyy"))
				{
					comFormat = "MM/dd/yyyy";
				}
				else
				{
					comFormat = currentDateFormat;
				}
				eg_stdate = DateUtil.changeDateFormat(eg_stdate,comFormat,userFormat);
				
				dateTime.put("eg_stdate",eg_stdate);
				dateTime.put("start_hr",start_hr);
			}
			if(eg_enddate!=null && !eg_enddate.equalsIgnoreCase("null") && eg_enddate.trim().length()>0)
			{
				if(DateUtil.isDate(eg_enddate,"MM/dd/yyyy"))
				{
					comFormat = "MM/dd/yyyy";
				}
				else
				{
					comFormat = currentDateFormat;
				}
				eg_enddate = DateUtil.changeDateFormat(eg_enddate,comFormat,userFormat);

				dateTime.put("eg_enddate",eg_enddate);
				dateTime.put("end_hr",end_hr);
			}
		}
		if(s_timeline==null)
		{
		  defaulttimelinevalue=egUI11.getValue("SEARCH_DISPLAY","Timeline");
		  s_timeline=defaulttimelinevalue;
	          gridObj.put("defaulttimelinevalue",defaulttimelinevalue);
		}
		else
		{
	           gridObj.put("defaulttimelinevalue",s_timeline);
		}

		EgAgentInfo agentInfo = new EgAgentInfo(EgConstants.MANAGER);
		EgTesterInfo tt = new EgTesterInfo(EgConstants.MANAGER);
		EgSpecsInfo specsInfo = new EgSpecsInfo("manager");
		boolean ddEnabled = EgMemInfo.ddEnabled;
		EgFormatInfo formatInfo = new EgFormatInfo ("manager");
		ArrayList excludeDDTestList = formatInfo.getHideDDTestList();
		Vector csvHeaders = new Vector();

		MonitorDAOFactory	monitorDaoFactory = MonitorDAOFactory.getInstance();
		EgServerDashBoardDAO dashboardDAO=monitorDaoFactory.getServerDashBoardDAO();
	

		trans.createFile("eg_format.ini");
		String strVarArr[] = trans.getVariables("FORMAT");
		String dummyTestArr[] = trans.getVariables("COMMON_DD_MAPPING");
	  
		String state=request.getParameter("state");
		state = (state==null||state.equalsIgnoreCase("null")||state.trim().length()==0)?"":state;
		ArrayList timlinelist = new ArrayList(Arrays.asList(options));
		//Collections.sort(timlinelist,String.CASE_INSENSITIVE_ORDER);
		JSONArray historyTmeLineList = new JSONArray();
		//historyTmeLineList.addAll(timlinelist);
		ListIterator itr = timlinelist.listIterator();
		String tempStr = "";
		while(itr.hasNext())
		{
			tempStr = (String)itr.next();
			JSONObject temp = new JSONObject();
			temp.put("displayField",mappingInfo.getTextDescription("monitor.common."+tempStr));
			temp.put("valueField",tempStr);
			historyTmeLineList.add(temp);
		}
		
       		// gridObj.put("eg_timeline_value",timeline);
		//gridObj.put("eg_timeline",timeline_json);

		String timeLineLbl = mappingInfo.getTextDescription("monitor.common.Timeline");
		String fromLbl = mappingInfo.getTextDescription("monitor.common.From");
		String toLbl = mappingInfo.getTextDescription("monitor.common.To");
		screenLabels.put("monitor.common.State",mappingInfo.getTextDescription("monitor.common.State"));
		screenLabels.put("monitor.common.Timeline",timeLineLbl);
		screenLabels.put("monitor.common.From",fromLbl);
		screenLabels.put("monitor.common.To",toLbl);
		screenLabels.put("monitor.common.Hr",mappingInfo.getTextDescription("monitor.common.Hr"));
		JSONObject poweredOpt = new JSONObject();
		poweredOpt.put("displayField",mappingInfo.getTextDescription("monitor.vmsearch.Powered on")); 
		poweredOpt.put("valueField","on"); 
	        stateGenOpts.add(poweredOpt);
	        JSONObject anyOpt = new JSONObject();
	        anyOpt.put("displayField",mappingInfo.getTextDescription("monitor.vmsearch.Any")); 
		anyOpt.put("valueField","any"); 
        	stateGenOpts.add(anyOpt);
		if((state!=null) && state.equalsIgnoreCase("any"))
		{
           		 gridObj.put("defaultstateopt","any");
		}

		if(state!=null&&state.equals("on"))  
		{
        
          		gridObj.put("defaultstateopt","on");
		}
		if(flage_header)
		{
			columnDetails.add(mappingInfo.getTextDescription("monitor.vmsearch.Virtual Machine  Name"));
			columnDetails.add(mappingInfo.getTextDescription("monitor.vmsearch.Server"));
			columnDetails.add(mappingInfo.getTextDescription("monitor.vmsearch.Component type"));
			csvHeaders.add(mappingInfo.getTextDescription("monitor.vmsearch.Virtual Machine  Name"));
			csvHeaders.add(mappingInfo.getTextDescription("monitor.vmsearch.Server"));
			csvHeaders.add(mappingInfo.getTextDescription("monitor.vmsearch.Component type"));
			if(state!=null&&state.equals("any"))
			{
				columnDetails.add(mappingInfo.getTextDescription("monitor.vmsearch.Powered on"));
				csvHeaders.add(mappingInfo.getTextDescription("monitor.vmsearch.Powered on"));
			}

			columnDetails.add(mappingInfo.getTextDescription("monitor.vmsearch.Measurement time"));
			csvHeaders.add(mappingInfo.getTextDescription("monitor.vmsearch.Measurement time"));
			columnDetails.add(mappingInfo.getTextDescription("monitor.vmsearch.Graph"));
			columnDetails.add(mappingInfo.getTextDescription("monitor.common.DD"));
			flage_header=false;
		}
		int valIdx = 0;
		try
		{
			StringBuffer s_title = new StringBuffer();
			String ftitle="";		
			s_title.append(mappingInfo.getTextDescription("monitor.search.Search results for"));
			s_title.append(" - ");
			s_title.append(mappingInfo.getTextDescription("monitor.search.VM"));
			s_title.append(" ");
			EgTablesInfo tables=new EgTablesInfo("manager");
			String uiFile = "eg_ui.ini";
			String s_iniFile_dir = EgInstallInfo.getInstallDir()+ "/manager/config/";
			IniFile egUI = new IniFile(s_iniFile_dir + uiFile);
				
			String usersdetailsperpage = egUI.getValue("SEARCH_DISPLAY","UserDetails_PerPage");
				EgCtxUserBean egCtxBean  =  new EgCtxUserBean();
			com.eg.IniFile egEx = new com.eg.IniFile(EgInstallInfo.getInstallDir()+ "/manager/config/eg_external.ini");
			String dispDate = null;
			String mode = null;
			com.egurkha.ini.IniUI ui = (com.egurkha.ini.IniUI)com.egurkha.ini.IniUI.getInstance();
			ErUtils erUtils = new ErUtils();
			EgDateInfo egDt=new EgDateInfo();
			java.util.Date local_date = new java.util.Date(egDt.egetUTCDate());
			Calendar cal = Calendar.getInstance();
			cal.setTime(local_date);
			cal.setTimeZone(egDt.getRealTimeZone());
			String start_date="";
			String end_date="";
			String hidden="VmSearch";
			String s_user="";
			Vector v_data=null;
			StringBuffer printQS=new StringBuffer();
			String title="";
			Vector v_columns=new Vector();
			s_user=request.getParameter("searchvalue");
			s_user=com.egurkha.util.StringUtils.replace(s_user,"|quots|","'");
			s_user=com.egurkha.util.StringUtils.replace(s_user,"|hash|","#");
			String temp_s_user = com.egurkha.util.StringUtils.decodeSecurityChar(s_user);
			if(temp_s_user!=null)
			{ 
			  s_title.append(temp_s_user);
			  s_title.append(" ");
			}
			
			//String state="any";
			if (s_user==null)
				s_user="";
			String searchValue = request.getParameter("searchvalue");
			String mainTitle = mappingInfo.getTextDescription("monitor.vmsearch.Search results for - "+searchValue);
			listData.add(mainTitle);
			listData.add("");
			listData.add(csvHeaders);
			Hashtable ht_server = (Hashtable)request.getAttribute("CitrixUser");
			if(ht_server!=null && ht_server.size()>0)
				session.setAttribute("CitrixUser",ht_server);
			Hashtable state_hash=new Hashtable();
			if(ht_server!=null&&ht_server.size()!=0)
			{
				Iterator keys=ht_server.keySet().iterator();
				while (keys.hasNext())
				{
					String user=(String)keys.next();
				
					if(user!=null && user.equals("endDateTime"))
					{
						continue;
					}
					v_data=(Vector)ht_server.get(user);
					String test="";
					Collections.sort(v_data,Collections.reverseOrder());
					int count_powerOff=0;
					int noofrows=0;
                    int noofcolumns=0;
					for(int i=0;i<v_data.size();i++)
					{
						Vector csvData = new Vector();
						JSONObject rowData = new JSONObject();
						String serverwithall=(String)v_data.get(i);
						String server="";
						String comptype="";
						String layer="";
						StringTokenizer st=new StringTokenizer(serverwithall,"|");
						String timeLineValue=st.nextToken();
						String strdateValue = "";
						if (timeLineValue!=null && !timeLineValue.equals("Recent"))
						{
							strdateValue=st.nextToken();
						}
						String strdate=st.nextToken();//serverwithall.substring(0,serverwithall.indexOf("|"));
						String serverwithcom=st.nextToken();//serverwithall.substring(serverwithall.indexOf("|")+1,serverwithall.lastIndexOf("|"));
						String connectionType=st.nextToken();//serverwithall.substring(serverwithall.lastIndexOf("|")+1);
						user=st.nextToken();
						
						//String poweredOn=st.nextToken();
						
						if(user.startsWith("+"))
							user=user.substring(1);
                        server=serverwithcom.substring(serverwithcom.indexOf(":")+1);
						String componentName=server;
						if (componentName.endsWith("NULL"))
						componentName=componentName.substring(0,componentName.lastIndexOf(":"));
							comptype=serverwithcom.substring(0,serverwithcom.indexOf(":"));
						
						String measureList="";
						String ddMeasure="";
						String ddTest = null;
						String layer_for_url=null;
						// for getting Measure from eg_external.ini
						if(connectionType!=null && connectionType.trim().length()>0)
						{
							String test_measure=egEx.getValue("VMSearch_Measure",connectionType);
							if(userObj.isOnlyVMAssigned() || userObj.isVMAssigned())
							{
								String insideView_test_measure = egEx.getValue("VMSearch_Measure",connectionType+":VM");
								if(insideView_test_measure != null && insideView_test_measure.trim().length() > 0)
									test_measure = insideView_test_measure;
							}
							if(test_measure!=null && test_measure.trim().length()>0)
							{
								StringTokenizer test_measure_token=new StringTokenizer(test_measure,":");
								if(test_measure_token.countTokens()==2)
								{
									test=test_measure_token.nextToken();
									measureList=test_measure_token.nextToken();
								}
							}
							String dd_test_measure=egEx.getValue("VMSearch_Measure",connectionType+":DD");
							if(userObj.isOnlyVMAssigned() || userObj.isVMAssigned())
							{
								String insideView_dd_test_measure = egEx.getValue("VMSearch_Measure",connectionType+":DD:VM");
								if(insideView_dd_test_measure != null && insideView_dd_test_measure.trim().length() > 0)
									dd_test_measure = insideView_dd_test_measure;
							}
							
							if(dd_test_measure!=null && dd_test_measure.trim().length()>0)
							{
								StringTokenizer test_measure_token=new StringTokenizer(dd_test_measure,":");
								if(test_measure_token.countTokens()==2)
								{
									ddTest=test_measure_token.nextToken();
									ddMeasure=test_measure_token.nextToken();
								}
							}

							layer_for_url=egEx.getValue("VMSearch_InsideviewLayer",connectionType);
						}
						//--end---

						String poweredOn =st.nextToken();
						poweredOn=EgDbInfo.formatValue(poweredOn);

						if(poweredOn!=null && poweredOn.equals("1"))// || !poweredOn.equals("-5")))
							poweredOn ="yes";
						else
							poweredOn ="no";
						if(state!=null&&!state.equals("any"))
						{
							if(poweredOn!=null&&poweredOn.equals("no"))
							{
								count_powerOff++;
								continue;
							}
						}
						layer=tables.getLayerForTest(test);
						if(layer!=null && layer.indexOf(",")>-1)
						{
							layer=layer.substring(0,layer.indexOf(","));
						}
						layer_for_url=(layer_for_url==null)?layer:layer_for_url;
						String tempServerwithAll=serverwithall.substring(serverwithall.indexOf("|")+1);
						strdateValue=tempServerwithAll.substring(0,tempServerwithAll.indexOf("|"));

						tempServerwithAll=tempServerwithAll.substring(tempServerwithAll.indexOf("|")+1);

						boolean use3DGraphs = false; //ui.use3DGraphs(IniUI.MONITOR);
						if(use3DGraphs)
						{
							mode ="3D";
						}
						else
							mode ="2D";

						Date startdateObj = new Date(strdate);
						Date dateObj=null;
						String starttime =strdate;
						Calendar cal_temp = new GregorianCalendar();
						cal_temp.setTime(startdateObj);
						cal_temp.add(Calendar.HOUR_OF_DAY,-1);
						//calendar.add(Calendar.HOUR,-4);

						dateObj = cal_temp.getTime();
						long l_starttime = dateObj.getTime();
						String startDate = egDt.egetDateUS(l_starttime);
						String sthr=startDate.substring(startDate.indexOf(" ")+1,startDate.indexOf(":"));
						starttime=startDate.substring(0,startDate.indexOf(" "));

						if(eg_stdate==null || eg_stdate.equals("null"))
						{
							eg_stdate=starttime;
						}

						//if(start_hr==null || start_hr.equals("null"))
						{
							start_hr=sthr;
						}

						Date enddateObj = new Date(strdate);
						cal_temp = new GregorianCalendar();
						cal_temp.setTime(enddateObj);
						cal_temp.add(Calendar.HOUR_OF_DAY,1);
						//calendar.add(Calendar.HOUR,-4);

						dateObj = cal_temp.getTime();
						long l_endtime = dateObj.getTime();
						String endtime = egDt.egetDateUS(l_endtime);
						String endhr=endtime.substring(endtime.indexOf(" ")+1,endtime.indexOf(":"));
						endtime=endtime.substring(0,endtime.indexOf(" "));
						timeLineValue="Any";

						if(eg_enddate==null || eg_enddate.equals("null"))
						{
							eg_enddate=endtime;
						}

						//if(end_hr==null || end_hr.equals("null"))
						{
							end_hr=endhr;
						}

						String userinfo=user;
						userinfo=com.egurkha.util.StringUtils.replace(userinfo, "\\", "\\\\");
						userinfo=com.egurkha.util.StringUtils.replace(userinfo,"#","|hash|");
						userinfo=com.egurkha.util.StringUtils.replace(userinfo,"%","|percent|");
						userinfo=com.egurkha.util.StringUtils.replace(userinfo,"&","|amp|");

						
						String layerQs="../servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&host="+EgURLEncoder.encode(server,"UTF-8")+"&comptype="+comptype+"&tab=LayerModel&toDashBoardLayer=true";
						String ddQs="../monitor/EgDiagnosis.jsp?site=NULL&host="+EgURLEncoder.encode(server.substring(0,server.lastIndexOf(":")),"UTF-8")+"&port="+server.substring(server.lastIndexOf(":")+1)+"&test="+ddTest+"&info="+EgURLEncoder.encode("*"+userinfo, "UTF-8")+"&msmt_host=&from=0&newWindow=true&measure="+ddMeasure+"&firsttime=true&flag=0 &starttime="+starttime+"&endtime="+endtime+"&starthr="+sthr+"&endhr="+endhr+"&timeline="+timeLineValue;
						
						//String graphQs="../monitor/EgGraphs.jsp?site=NULL&host="+EgURLEncoder.encode(server.substring(0,server.lastIndexOf(":")),"UTF-8")+"&port="+server.substring(server.lastIndexOf(":")+1)+"&layer="+layer+"&test="+test+"&comptype="+comptype+"&info=*"+EgURLEncoder.encode(user,"UTF-8")+"&starttime="+starttime+"&endtime="+endtime+"&starthr="+sthr+"&endhr="+endhr+"&measure="+measureList+"&gtype=1&msmt_host=&mode="+mode+"&timeLine="+timeLineValue+"&monitorSkin="+monitor_Skin;
						//String graphQs="/final/monitor/EventsGraph.jsp?pageToShow=graph&url=EgGraphs.jsp?site=NULL&host="+EgURLEncoder.encode(server.substring(0,server.lastIndexOf(":")),"UTF-8")+"&port="+server.substring(server.lastIndexOf(":")+1)+"&layer="+layer+"&test="+test+"&comptype="+comptype+"&info=*"+EgURLEncoder.encode(user,"UTF-8")+"&starttime="+starttime+"&endtime="+endtime+"&starthr="+sthr+"&endhr="+endhr+"&measure="+measureList+"&gtype=1&msmt_host=&mode="+mode+"&timeLine="+timeLineValue+"&monitorSkin="+monitor_Skin;

						String graphQs="";
						dispDate = DateUtil.changeDateFormat(strdate,"MM/dd/yyyy HH:mm:ss",currentDateFormat +" HH:mm:ss");
						String orgDate = dispDate;
						EgTimeZoneConverter timeZoneConverter = new EgTimeZoneConverter(dispDate , u_ser);
						dispDate = timeZoneConverter.getDateTime();
						String compNameWithType = server + ":" + comptype;

						Hashtable Valid_info=new Hashtable();
						ArrayList insideview_vm_list=new ArrayList();

						String key_for_hash=comptype+"^eg^"+server+"^eg^"+layer_for_url;

						if(state_hash!=null && state_hash.size()>0 && state_hash.containsKey(key_for_hash))
						{
							insideview_vm_list=(ArrayList)state_hash.get(key_for_hash);
						}
						else
						{
							VMDesktopBean vmdeskBean=new VMDesktopBean(comptype,server,layer_for_url);
							Valid_info=vmdeskBean.getInfoForTest();
							if(Valid_info!=null && Valid_info.size()>0)
							{
								Enumeration vm_keys=Valid_info.keys();
								while(vm_keys.hasMoreElements())
								{
									String key = (String)vm_keys.nextElement();
									insideview_vm_list.add(key.toLowerCase());
								}
							}

							if(insideview_vm_list!=null)
							{
								state_hash.put(key_for_hash,(ArrayList)insideview_vm_list);
							}
						}
                        String  s_qryString="";
						String  s_qryString1="";
						String  s_qryString2="";

						String mHost = "";
						List agents=new LinkedList();
						String nick_name = server.substring(0,server.lastIndexOf(":"));
						EgExternalInfo egExternalInfo=new EgExternalInfo("manager");
						agents=egExternalInfo.getAgentsFor(test,comptype,nick_name);
						if (agents!=null && agents.size()>0)
						{
							mHost = (String) agents.get(0);
						}
						else
						{
							mHost=nick_name;
						}
						agents=egExternalInfo.getAgentsFor(test,comptype,nick_name);
						searchValue = request.getParameter("searchvalue");
						searchValue=com.egurkha.util.StringUtils.replace(searchValue,"|quots|","'");
						searchValue=com.egurkha.util.StringUtils.replace(searchValue,"|hash|","#");

						
						String searchType = "";
						searchType = request.getParameter("searchtype");
						s_qryString="/final/monitor/eGVMDetails.jsp?comp="+EgURLEncoder.encode(server,"UTF-8")+"&comptype="+comptype+"&info="+EgURLEncoder.encode("*"+userinfo, "UTF-8")+"&compName="+EgURLEncoder.encode(server+":"+comptype,"UTF-8")+"&componentName="+componentName+"&username="+EgURLEncoder.encode(s_user, "UTF-8")+"&searchval="+EgURLEncoder.encode(searchValue, "UTF-8")+"&searchtype="+EgURLEncoder.encode(searchType, "UTF-8")+"&msmt_host="+EgURLEncoder.encode(mHost,"UTF-8")+"&searchuser="+EgURLEncoder.encode(searchType+" "+searchValue,"UTF-8");
						if((s_timeline!=null && !s_timeline.equalsIgnoreCase("null") && s_timeline.trim().length()>0) && (eg_stdate!=null && !eg_stdate.equalsIgnoreCase("null") && eg_stdate.trim().length()>0))
						{
							//s_qryString = s_qryString + "&eg_timeline="+EgURLEncoder.encode(s_timeline,"UTF-8")+"&eg_stdate="+EgURLEncoder.encode(eg_stdate,"UTF-8")+"&eg_enddate="+EgURLEncoder.encode(eg_enddate,"UTF-8")+"&starthr="+EgURLEncoder.encode(start_hr,"UTF-8")+"&endhr="+EgURLEncoder.encode(end_hr,"UTF-8")+"&startmin_h="+EgURLEncoder.encode(startmin_h,"UTF-8")+"&endmin_h="+EgURLEncoder.encode(endmin_h,"UTF-8");

							s_qryString = s_qryString + "&eg_timeline="+EgURLEncoder.encode(s_timeline,"UTF-8")+"&eg_stdate="+EgURLEncoder.encode(starttime,"UTF-8")+"&eg_enddate="+EgURLEncoder.encode(endtime,"UTF-8")+"&starthr="+EgURLEncoder.encode(start_hr,"UTF-8")+"&endhr="+EgURLEncoder.encode(end_hr,"UTF-8")+"&startmin_h="+EgURLEncoder.encode(startmin_h,"UTF-8")+"&endmin_h="+EgURLEncoder.encode(endmin_h,"UTF-8");

							if(!s_timeline.equals("Recent"))
								s_qryString = s_qryString + "&eg_tbound="+EgURLEncoder.encode(eg_tbound,"UTF-8");
							else if(state!=null && !state.equalsIgnoreCase("null") && state.trim().length()>0)
								s_qryString = s_qryString +"&state="+state;
						}
						String tmp_s_timeline=s_timeline;
						if(tmp_s_timeline!=null && tmp_s_timeline.equals("Recent"))
						{
							tmp_s_timeline = "24 hours";
						}
						
						boolean isVMlevel = false;
						try
						{
							if(userObj.isOnlyVMAssigned() || userObj.isVMAssigned())
							{
								isVMlevel = true;
								s_qryString ="/final/monitor/egInsideviewDashboard.jsp?getFor=measure&comp="+EgURLEncoder.encode(server,"UTF-8")+"&comptype="+comptype+"&Layer="+layer_for_url+"&info="+EgURLEncoder.encode(userinfo, "UTF-8")+"&compName="+EgURLEncoder.encode(server+":"+comptype,"UTF-8")+"&source=Vmsearch&isVM=true&servername=&userName=null&stateName=all&check=uservms&from=Vmsearch";
							}
						}
						catch(Exception ee)
						{
						}
						//componentMeasureTabset
						String hostname=EgURLEncoder.encode(server.substring(0,server.lastIndexOf(":")),"UTF-8");
						String port = server.substring(server.lastIndexOf(":")+1);
						
						ddQs="../monitor/EgDiagnosis.jsp?site=NULL&host="+EgURLEncoder.encode(server.substring(0,server.lastIndexOf(":")),"UTF-8")+"&port="+server.substring(server.lastIndexOf(":")+1)+"&test="+ddTest+"&info="+EgURLEncoder.encode("*"+userinfo, "UTF-8")+"&msmt_host=&from=0&newWindow=true&measure="+ddMeasure+"&firsttime=true&flag=0 &starttime="+starttime+"&endtime="+endtime+"&starthr="+sthr+"&endhr="+endhr+"&timeline="+timeLineValue;
						if(!isVMlevel)
							ddQs="../monitor/EgDiagnosis.jsp?site=NULL&host="+EgURLEncoder.encode(server.substring(0,server.lastIndexOf(":")),"UTF-8")+"&port="+server.substring(server.lastIndexOf(":")+1)+"&test="+ddTest+"&info=NONE&msmt_host=&from=0&newWindow=true&measure="+ddMeasure+"&firsttime=true&flag=0 &starttime="+starttime+"&endtime="+endtime+"&starthr="+sthr+"&endhr="+endhr+"&timeline="+timeLineValue;

						String dLink = "/final/monitor/EgDiagnosis.jsp?site=NULL&host="+hostname+"&port="+port+"&test="+ddTest+"&isPopUp=true";
						
						String compddLink = dLink + "&info=*"+EgURLEncoder.encode(userinfo,"UTF-8")+"&msmt_host="+EgURLEncoder.encode(mHost,"UTF-8")+"&from=0&measure="+ddMeasure+"&flag=1&firsttime=true&isVM="+isVMlevel+"&comptype="+EgURLEncoder.encode(comptype,"UTF-8");
						
						if(!isVMlevel)
							compddLink = dLink + "&info=NONE&msmt_host="+EgURLEncoder.encode(mHost,"UTF-8")+"&from=0&measure="+ddMeasure+"&flag=1&firsttime=true&comptype="+EgURLEncoder.encode(comptype,"UTF-8")+"&timeline="+tmp_s_timeline;

						String histLink="../monitor/dispComponentHistory.jsp?site=NULL&isVM="+isVMlevel+"&info=" + EgURLEncoder.encode(user,"UTF-8") + "&test=" + test + "&component=" +EgURLEncoder.encode(server+":"+comptype,"UTF-8");
 
						String ddLink = response.encodeURL("../monitor/componentMeasureTabSet.jsp?")+"type="+EgURLEncoder.encode(comptype,"UTF-8")+"&site=NULL&host="+hostname+"&port="+port+"&info="+EgURLEncoder.encode(user,"UTF-8")+"&state="+state+"&messy="+measureList+"&test="+test+"&msmt_host="+EgURLEncoder.encode(mHost,"UTF-8")+"&clicked=dd&from=measurespage&isVM="+isVMlevel;

						String compgraphLink = "/final/monitor/dispComponentGraphs.jsp?site=NULL&isVM="+isVMlevel+"&host=" +hostname+"&port="+port+"&layer="+layer+"&test="+test+"&comptype="+EgURLEncoder.encode(comptype,"UTF-8");


						String  graphLink = compgraphLink + "&info=*"+EgURLEncoder.encode(user,"UTF-8")+ "&gtype=1&measure="+measureList+ "&msmt_host="+	EgURLEncoder.encode(mHost,"UTF-8")+"&state="+state+"&timeLine="+tmp_s_timeline;

						String compsummarygraphLink ="../monitor/dispComponentSummaryGraphs.jsp?site=NULL&host=" +EgURLEncoder.encode(hostname,"UTF-8")+ "&port=" + port + "&layer=" +EgURLEncoder.encode(layer,"UTF-8")+ "&test=" + test + "&comptype="+EgURLEncoder.encode(comptype,"UTF-8");

						String summarygraphLink = compsummarygraphLink + "&info=*"+EgURLEncoder.encode(user,"UTF-8")+ "&gtype=1&measure="+measureList+ "&msmt_host="+	EgURLEncoder.encode(mHost,"UTF-8")+"&state="+state;

						String comptrendgraphLink ="../monitor/dispComponentTrendGraphs.jsp?site=NULL&isVM="+isVMlevel+"&host=" +EgURLEncoder.encode(hostname,"UTF-8")+ "&port=" + port + "&layer=" +EgURLEncoder.encode(layer,"UTF-8")+ "&test=" + test + "&comptype="+EgURLEncoder.encode(comptype,"UTF-8");

						String trendgraphLink = comptrendgraphLink + "&info=*"+EgURLEncoder.encode(user,"UTF-8")+ "&gtype=1&measure="+measureList+ "&msmt_host="+	EgURLEncoder.encode(mHost,"UTF-8")+"&state="+state;

						String  aggLink="../monitor/dispAggComponentGraphs.jsp?site=NULL&isVM="+isVMlevel+"&host=" +EgURLEncoder.encode(hostname,"UTF-8")+ "&port=" + port + "&layer=" +EgURLEncoder.encode(layer,"UTF-8")+ "&test=" + test + "&comptype="+EgURLEncoder.encode(comptype,"UTF-8");

						String historyLink = histLink+"&measure="+measureList;

						String feedLink="/final/monitor/dispComponentFeedback.jsp?site=NULL&isVM="+isVMlevel+"&trgthost="+hostname+"&port="+port+"&test="+test+"&comptype="+EgURLEncoder.encode(comptype,"UTF-8");

						String portForMsmtTime="NULL";
						String key=componentName+":"+portForMsmtTime+":"+test+":"+mHost;
						String msmtTimeStr=dashboardDAO.getMeasureLastMsmtTime(key,user);
						String msmtTimeStr2="";
						try
						{
							SimpleDateFormat df=new SimpleDateFormat("MM/dd/yyyy*HH:mm:ss");
							SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
							java.util.Date msd=sdf2.parse(msmtTimeStr);
							msmtTimeStr2 =df.format(msd);
						}
						catch(Exception eexx)
						{
							System.out.println("Exception--->"+eexx.getMessage());
							eexx.printStackTrace();
						}

						String feedbackLink =  feedLink+"&info=*"+EgURLEncoder.encode(user,"UTF-8")+ "&measure="+measureList+ "&msmttime="+msmtTimeStr2 +"&msmt_host="+EgURLEncoder.encode(mHost,"UTF-8");

						String aggregateLink=aggLink + "&info=*"+EgURLEncoder.encode(user,"UTF-8")+ "&gtype=1&measure="+measureList+ "&msmt_host="+	EgURLEncoder.encode(mHost,"UTF-8")+"&state="+state;

						String measureLink = response.encodeURL("../monitor/componentMeasureTabSet.jsp?")+"type="+EgURLEncoder.encode(comptype,"UTF-8")+"&site=NULL&host="+hostname+"&port="+port+"&info="+EgURLEncoder.encode(user,"UTF-8")+"&state="+state+"&messy="+measureList+"&from=measurespage&dd_disp=yes&test="+test+"&msmt_host="+EgURLEncoder.encode(mHost,"UTF-8");

						graphQs = measureLink;
						
						ddQs = ddLink;
						//componentMeasureTabset
						if((insideview_vm_list!=null && insideview_vm_list.contains(user.toLowerCase())) && (poweredOn!=null && poweredOn.equals("yes")))
						{
							//s_qryString ="../monitor/egInsideviewDashboard.jsp?getFor=measure&comp="+EgURLEncoder.encode(server,"UTF-8")+"&comptype="+comptype+"&Layer="+layer_for_url+"&info="+EgURLEncoder.encode(user,"UTF-8")+"&compName="+EgURLEncoder.encode(compNameWithType,"UTF-8")+"&componentName="+EgURLEncoder.encode(componentName,"UTF-8")+"&fromVmSearch=yes";

							//s_qryString ="../monitor/egInsideviewDashboard.jsp?comp="+EgURLEncoder.encode(server,"UTF-8")+"&comptype="+comptype+"&info="+user+"&compName="+EgURLEncoder.encode(compNameWithType,"UTF-8")+"&componentName="+componentName;

							String strShownInsideview=egEx.getValue("User_VM_Search","shownInsideview");
							if(strShownInsideview!=null && strShownInsideview.trim().length()>0 && (strShownInsideview.equalsIgnoreCase("true") || strShownInsideview.equalsIgnoreCase("yes")))
							{
								s_qryString ="../monitor/egInsideviewDashboard.jsp?getFor=measure&comp="+EgURLEncoder.encode(server,"UTF-8")+"&comptype="+comptype+"&Layer="+layer_for_url+"&info="+EgURLEncoder.encode(user,"UTF-8")+"&compName="+EgURLEncoder.encode(compNameWithType,"UTF-8")+"&searchuser="+EgURLEncoder.encode(searchType+" "+searchValue,"UTF-8");
							}

							JSONObject linkObj = new JSONObject();
							linkObj.put("VMUSER_LINK_TEXT",user);
							linkObj.put("VMUSER_LINK_URL",s_qryString);
							rowData.put("COLUMN_0",linkObj);
							csvData.add(user);
						}
						else
						{
							JSONObject linkObj = new JSONObject();
							linkObj.put("VMUSER_LINK_TEXT",user);
							linkObj.put("VMUSER_LINK_URL",s_qryString);
							rowData.put("COLUMN_0",linkObj);
							csvData.add(user);
						}
						//String tmpLayerQs = "from=list^tab=LayerModel^toDashBoardLayer=true^qctr=2^fromPage=GlobalSearchList^fromalarm=null^host="+EgURLEncoder.encode(server,"UTF-8")+"^comptype="+EgURLEncoder.encode(comptype,"UTF-8")+"^site=NULL^searchValueandType="+EgURLEncoder.encode(searchType+" "+searchValue,"UTF-8");

						//	String tmpLayerQs="site=NULL^qctr=1^fromalarm=1^fromPage=vm^newWindow=false^comptype="+EgURLEncoder.encode(comptype,"UTF-8")+"^host="+EgURLEncoder.encode(server,"UTF-8")+"^layer="+EgURLEncoder.encode(layer,"UTF-8")+"^test="+EgURLEncoder.encode(test,"UTF-8")+"-"+EgURLEncoder.encode(user,"UTF-8")+"^msmt_host=^isFromVmHost=true^gotoLayerModel=true^tab=LayerModel^toDashBoardLayer=true^isTotalVm=null^poweredOnVMs=null^tstate=GOOD^priority=10^searchValueandType="+EgURLEncoder.encode(searchType+" "+searchValue,"UTF-8")+"&searchString="+EgURLEncoder.encode(searchType+" "+searchValue,"UTF-8");
						String tmp_user = "";
						if(user!=null && user.trim().length()>0 && !user.equalsIgnoreCase("NULL"))
						{
							tmp_user=com.egurkha.util.StringUtils.replace(user,"#","|hash|");
							tmp_user=com.egurkha.util.StringUtils.replace(user,"%","|percent|");
							tmp_user=com.egurkha.util.StringUtils.replace(user,"&","|amp|");
							tmp_user = com.egurkha.util.StringUtils.encodeSecurityChar(tmp_user);
						}
						String tmpLayerQs = "site|eq|NULL^qctr|eq|2^fromalarm|eq|1^fromPage|eq|vm^newWindow|eq|false^comptype|eq|"+comptype+"^host|eq|"+server+"^layer|eq|"+layer+"^test|eq|"+test+"-"+tmp_user+"^msmt_host|eq|^isFromVmHost|eq|true^gotoLayerModel|eq|true^tab|eq|LayerModel^toDashBoardLayer|eq|true^isTotalVm|eq|null^poweredOnVMs|eq|null^tstate|eq|GOOD^priority|eq|10^searchValueandType|eq|"+searchType+" "+searchValue+"^searchString|eq|"+searchType+" "+searchValue;
						if(state!=null && !state.equalsIgnoreCase("null") && state.trim().length()>0)
							tmpLayerQs = tmpLayerQs +"^state|eq|"+state;
						if(tmpLayerQs!=null && tmpLayerQs.trim().length()>0 && !tmpLayerQs.equalsIgnoreCase("NULL"))
							tmpLayerQs = tmpLayerQs + "^isFromVmSearch|eq|true";

						tmpLayerQs=com.egurkha.util.StringUtils.encodeSecurityChar(tmpLayerQs);
						JSONObject linkObj1 = new JSONObject();
						linkObj1.put("VMCOMPNAME_LINK_TEXT",componentName);
						if(!userObj.isOnlyVMAssigned())
							linkObj1.put("VMCOMPNAME_LINK_URL",EgURLEncoder.encode(tmpLayerQs,"UTF-8"));
						rowData.put("COLUMN_1",linkObj1);
						rowData.put("COLUMN_2",mappingInfo.getComponentTypeDescription(comptype));
						//rowData.put("COLUMN_2",comptype);
						csvData.add(componentName);
						csvData.add(mappingInfo.getComponentTypeDescription(comptype));
						boolean showDDIcon = false;
						String msmtHost = "";
						String hostName = server.substring(0,server.lastIndexOf(":"));

						if(ddEnabled)
						{
							Vector measures = new Vector();

							if(strVarArr!=null && strVarArr.length>0)
							{
								for(int sva=0; sva<strVarArr.length; sva++)
								{
									if(strVarArr[sva].startsWith(ddTest))
									{
										String meas = strVarArr[sva].substring(strVarArr[sva].indexOf(":")+1,strVarArr[sva].length());
										if(meas!=null && !measures.contains(meas))
										{
											measures.add(meas);
										}
									}
								}
							}
							
							if(dummyTestArr!=null && dummyTestArr.length>0)
							{
								for(int dta=0; dta<dummyTestArr.length; dta++)
								{
									if(dummyTestArr[dta].startsWith(ddTest))
									{
										String meas = dummyTestArr[dta].substring(dummyTestArr[dta].indexOf(":")+1,dummyTestArr[dta].length());
										if(meas!=null && !measures.contains(meas))
										{
											measures.add(meas);
										}
									}
								}
							}

							if(measures.contains(ddMeasure))
							{
								ArrayList DDEnabledList=tt.DefaultDDEnabledTypes();
								boolean isRemoteDetailed = false;
								if(DDEnabledList!=null && DDEnabledList.size()>0 && DDEnabledList.contains(comptype))
								{
									isRemoteDetailed=true;
								}
								else
								{
									isRemoteDetailed = tt.getRemoteDetailed();
								}

								boolean isAgentlessServer = false;
								if (!isRemoteDetailed)
									isAgentlessServer = agentInfo.isAgentlessServer(hostName, comptype);

								//Fix to hide DD icon based on Ini entry
								if(excludeDDTestList != null && excludeDDTestList.size() > 0 && excludeDDTestList.contains(ddTest))
								{
									showDDIcon = false;
								}
								else if (ui.getVirtualServerTypes().contains(comptype)|| !isAgentlessServer || specsInfo.isTestExternal(ddTest))
								{
									showDDIcon = true; //dd.ShowDDData("NULL",hostName,ddTest,ddMeasure,"+",msmtHost);
								}
							}
						}

						if(state!=null&&state.equals("any"))
						{       
							   
								if(poweredOn!=null&&poweredOn.equals("yes"))
								{
                                           
									JSONObject poweredonobj = new JSONObject();
						                	poweredonobj.put("POWERED_LINK_TEXT","Powered On");
						                     	poweredonobj.put("POWERED_LINK_TITLE",mappingInfo.getTextDescription("monitor.common.Powered On"));
								     	rowData.put("COLUMN_3",poweredonobj);
								     	csvData.add(mappingInfo.getTextDescription("monitor.common.Powered On"));
								}
								else
								{           
									JSONObject poweredoffobj = new JSONObject();
						                     	poweredoffobj.put("POWERED_LINK_TEXT","Powered Off");
						                     	poweredoffobj.put("POWERED_LINK_TITLE",mappingInfo.getTextDescription("monitor.common.Powered Off"));
									rowData.put("COLUMN_3",poweredoffobj);
									csvData.add(mappingInfo.getTextDescription("monitor.common.Powered Off"));
			   					 }

									rowData.put("COLUMN_4",dispDate);	
									csvData.add(dispDate);
                            				JSONObject linkObj2 = new JSONObject();
							linkObj2.put("VMGRAPH_LINK_IMAGE","vmgraphicon");

							if(orgDate!=null && orgDate.trim().length()>0)
							{
								orgDate = orgDate.trim();
								String temDate= orgDate;

								if(orgDate.indexOf(":")>-1)
								{
									int colonCountCheck = orgDate.length() - com.egurkha.util.StringUtils.replace(orgDate,":","").length();
									if(colonCountCheck == 2)	
										temDate = orgDate.substring(0,orgDate.lastIndexOf(":"));
								}

								graphQs += "&fromSearch=true&latime="+temDate;
								ddQs += "&fromSearch=true&latime="+temDate;
							}

							linkObj2.put("VMGRAPH_LINK_URL",graphQs);
                            linkObj2.put("VMGRAPH_ALT",mappingInfo.getTextDescription("monitor.common.GRAPH")); 
							rowData.put("COLUMN_5",linkObj2);
							if(showDDIcon)
							{
								//linksMap.put(ddTest+"#"+ddMeasure+"#"+user+"#"+mHost+"compddlink", compddLink);
								linksMap.put(test+"#"+measureList+"#"+user+"#"+mHost+"compddlink", compddLink);
								JSONObject linkObj3 = new JSONObject();
								linkObj3.put("VMDD_LINK_IMAGE","vmddicon");
								linkObj3.put("VMDD_LINK_URL",ddQs);
								linkObj3.put("VMDD_ALT",mappingInfo.getTextDescription("monitor.vmsearch.DIAGNOSIS"));
								rowData.put("COLUMN_6",linkObj3);
                			}
						}//end of state
						else
						{ 
                            rowData.put("COLUMN_3",dispDate);	
							csvData.add(dispDate);
                            JSONObject linkObj2 = new JSONObject();
							linkObj2.put("VMGRAPH_LINK_IMAGE","vmgraphicon");
							linkObj2.put("VMGRAPH_LINK_URL",graphQs);
                            linkObj2.put("VMGRAPH_ALT",mappingInfo.getTextDescription("monitor.common.GRAPH")); 
							rowData.put("COLUMN_4",linkObj2);
							if(showDDIcon)
							{
								linksMap.put(test+"#"+measureList+"#"+user+"#"+mHost+"compddlink", compddLink);
                                JSONObject linkObj3 = new JSONObject();
								linkObj3.put("VMDD_LINK_IMAGE","vmddicon");
								linkObj3.put("VMDD_LINK_URL",ddQs);
								linkObj3.put("VMDD_ALT",mappingInfo.getTextDescription("monitor.vmsearch.DIAGNOSIS"));
								rowData.put("COLUMN_5",linkObj3);
                			}
						}
						// Rights Symbol replace
						user = com.egurkha.util.StringUtils.replace(user,"\u00AE","|rights|");

						linksMap.put(test+"#"+measureList+"#"+user+"#"+mHost+"compfeedbacklink", aggregateLink);

						linksMap.put(test+"#"+measureList+"#"+user+"#"+mHost+"compgraphlink", graphLink);

						linksMap.put(test+"#"+measureList+"#"+user+"#"+mHost+"compsummarygraphlink", summarygraphLink);

						linksMap.put(test+"#"+measureList+"#"+user+"#"+mHost+"comptrendgraphlink", trendgraphLink);

						linksMap.put(test+"#"+measureList+"#"+user+"#"+mHost+"comphistorylink", historyLink);

						linksMap.put(test+"#"+measureList+"#"+user+"#"+mHost+"compfeedbacklink", feedbackLink);

                        gridData.add(rowData);
 						listData.add(csvData);
					}//endoffor
					session.setAttribute("Tablinks", linksMap);
					if(((count_powerOff)==v_data.size()) && flage_header)
					{
					  // No powered on VMs found for the current selection
					 // System.out.println("no powered condition");
					   gridObj.put("searchmessage",mappingInfo.getTextDescription("monitor.vmsearch.No powered on VMs found for the current selection"));
					}
				}//endofwhile
			}//endofif
			else
			{
				rootJson.put("noDataErrorMsg",mappingInfo.getTextDescription("monitor.vmsearch.No data available"));
			}
			if(listData!=null)
				session.setAttribute("userSearchCsvData", listData);

			   // System.out.println("request.getQueryString()==>"+request.getQueryString());
			/*   String queryString="";
			queryString = null;
			queryString = request.getQueryString();
			queryString=(String)ErUtils.prepareQueryString(request.getParameterMap());*/
			 /*  if(request.getQueryString()!=null)
			{
				session.setAttribute("monitorLastSession","/final/monitor/eg_vmsearchjson.jsp")
			}*/
			//else
			//{
				//session.setAttribute("monitorLastSession","/final/servlet/com.eg.EgSearchController?monCmd=componentList&from=TreeMenu&action=component&searchIndComps=checked");
			//}
			String mngrIProc = new IniFile(new com.eg.EgConfigInfo("manager").getDbFile()).getValue("DB_PROPERTIES","ManagerUrl");
			String htmlFileName = mngrIProc + "/final/monitor/eGVMSearchPrint.jsp;jsessionid="+session.getId()+"?";
			String csvFilePath = "/final/monitor/eGVMSearchPrint.jsp;jsessionid="+session.getId()+"?";
			session.setAttribute("USERSEARCH_PDF_URL",htmlFileName);
			session.setAttribute("REPORT_NAME","userSearch");
			session.setAttribute("title","User Search Details");
			session.setAttribute("frmPage","userSearch");

			int increment = Integer.parseInt(usersdetailsperpage);
			int optionCount = 5;
			String rowsPerPage[] = new String[optionCount];
			for(int i=0;i<optionCount;i++)
			{
				int j=i+1;
				rowsPerPage[i] = "" + j* increment;
			}
			JSONArray eventsPerPageJson = new JSONArray();
			String rowCount = request.getParameter("eventsPerPage");
			if(rowCount == null || rowCount.equals("null"))
				rowCount = rowsPerPage[0];
			for(int i=0;i<rowsPerPage.length;i++)
			{
				JSONObject eventsPerPageJsonObj = new JSONObject();
				eventsPerPageJsonObj.put("displayField",rowsPerPage[i]);
				eventsPerPageJsonObj.put("valueField",rowsPerPage[i]);
				eventsPerPageJson.add(eventsPerPageJsonObj);
			}
			gridObj.put("eventsPerPage",eventsPerPageJson);
			gridObj.put("eventsPerPageValue",rowCount);
				ftitle=s_title.toString();
					gridObj.put("searchmessage",mappingInfo.getTextDescription("monitor.vmsearch.No  data available for the current search"));
					gridObj.put("searchtitle",ftitle);
				    gridObj.put("searchtype","vmsearch");
				    gridObj.put("searchParam",temp_s_user);
					gridObj.put("screenLabels",screenLabels);
                    gridObj.put("stateGenOpts",stateGenOpts);
						if(dateTime!=null && dateTime.size()>0)
							gridObj.put("dateTime",dateTime);
					gridObj.put("timeLineList",historyTmeLineList);
				gridObj.put("usersdetailsperpage",rowCount);
					//gridObj.put("monitor_Skin",monitor_Skin);
	                gridObj.put("COLUMNS",columnDetails);
				    gridObj.put("DATA",gridData);
					rootJson.put("SEARCH_DATA",gridObj);
					rootJson.put("csvFilePath",csvFilePath);
					out.println(rootJson.toString());
					//System.out.println("gridArray===>"+gridData);
				 /*if ( request.getQueryString() != null )
				{
					session.setAttribute("globalSearchLastSession","/final/monitor/eGSearch.jsp?"+request.getQueryString());
				}*/   
				/*	String queryString="";
			queryString=ErUtils.prepareQueryString(request.getParameterMap());
			System.out.println("queryString####===>"+queryString);
				if(queryString!=null)
			{
				session.setAttribute("monitorLastSession","/final/servlet/com.eg.EgSearchController?"+queryString);
			}
			else
			{
				session.setAttribute("monitorLastSession","/final/monitor/eg_vmsearchjson.jsp");
			}*/
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
%>
