<%@ page import="com.egurkha.util.StringUtils"%>
<%@ page import="java.lang.management.ManagementFactory"%>
<%@ page import="java.lang.management.RuntimeMXBean"%>
<%@ page import="com.eg.EgConMonHelper"%>
<%@ page import="java.util.*"%>

<%
	RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
	List arguments = runtimeMxBean.getInputArguments();
	String sessionInUse = request.getParameter("sessionInUse");
	String pwd = request.getParameter("pwd");
	String authenticated = (String)session.getAttribute("authenticated");

	if (authenticated == null)
	{
		// Direct access from the browser address bar or from inside the toolkit via the tool
		if (pwd == null)
		{
			if (sessionInUse == null)
			{
				response.sendRedirect(request.getContextPath()+"/toolkitlogin?comeFrom=Jdkversion");
			}
			else
			{
%>
				<script>
					window.parent.location.href ="/final/toolkitlogin";
				</script>
<%
			}
		}
		else
		{
			// Direct access from the browser address bar
			if (!pwd.equals(EgConMonHelper.executePwd))
			{
				response.sendRedirect(request.getContextPath()+"/toolkitlogin?comeFrom=Jdkversion");
			}
			else
			{
				session.setAttribute("reqFromForTk","Jdkversion");
				String redirectURL = request.getContextPath()+"/toolkit";
				response.sendRedirect(redirectURL);
			}
		}
	}
	else
	{ 
		// Direct access from the browser address bar and session in use
		if (sessionInUse == null)
		{
			response.sendRedirect(request.getContextPath()+"/toolkit");
		}
	}
	session.setAttribute("reqFromForTk","Jdkversion");

	String comeFrom = request.getParameter("comeFrom");
	if (!StringUtils.isNull(comeFrom) && comeFrom.equals("Jdk"))
	{
		session.setAttribute("treeViewSrc","Jdkversion");
	}
	String manager_label = com.eg.EgInstallInfo.isSuperManager ? "SuperManager" : "Manager";
%>

<html>
<link REL = "StyleSheet" href = "/final/admin/eg_styles/adminstyle_blue.css"/>
<head>
<script language="javascript" src="/final/admin/eg_scripts/timeout.js"></script>
<script>
document.onscroll = function()
{
	clearTimeout(time);
	time = setTimeout(logout,timeoutTime); 
}
</script>
</head>
<body>
<table align="center" width="90%" cellspacing="0" cellpadding="4" border="0" style="margin-top:20px">
	<tr>
		<td height="24" nowrap align="right" width="25%" class="eg_cellbglits"><img src="/final/admin/eg_images/info2.gif"> </td>
		<td height="24" nowrap align="left" class="eg_cellbglits">
		This page enables the administrator to view <%=manager_label%> JDK and JVM information.</td>
	</tr>
</table>
<table border="0" cellpadding="4" cellspacing="0" width="75%" align="center" style="margin-top:20px;margin-bottom:5px">
	<tr>
		<td id="linebottomright" colspan="2" align="center" style="border-width:1px"><label style="font-weight:bold;"><%=manager_label%> JDK Information<label></td>
	</tr>
	<tr>
		<td align="left" class="table_head"><b>Name</b></td>
		<td align="left" class="table_head"><b>Value</b></td>
	</tr>
	<tr>
		<td id="linebottomright" class="tdborder" align="left" style="word-wrap:break-word;border-left-width:1px;">JDK version used by the eG manager</td>
		<td id="linebottomright" class="tdborder" align="left" style="word-wrap:break-word"><%=System.getProperty("java.version")%>
	</tr>
</table>
<%
	int argSize = arguments.size();
	if (arguments != null && argSize > 0)
	{
%>
<table border="0" cellpadding="4" cellspacing="0" width="75%" align="center" style="margin-top:20px;margin-bottom:20px">
	<tr>
		<td id="linebottomright" align="center" style="border-width:1px"><label style="font-weight:bold;"><%=manager_label%> JVM Information<label></td>
	</tr>
	<tr>
		<td colspan="2" align="left" class="table_head"><label style="font-weight:bold;">JVM Input Arguments<label></td>
	</tr>
<%
		for (int a=0;a < argSize;a++)
		{
			String argName = (String)arguments.get(a);
			if (!argName.startsWith("-"))
			{
				continue;
			}
%>
		<tr>
			<td colspan ="2" id="linebottomright" class="tdborder" align="left" style="word-wrap:break-word;border-left-width:1px;"><%=argName%></td>
		</tr>
<%
		}
%>
</table>
<%
	}
%>
</body>
</html>



