JCS-207: Fix JCS admin page, add some styling.
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdmin.jsp b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdmin.jsp
index b01bef0..313d349 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdmin.jsp
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdmin.jsp
@@ -16,295 +16,293 @@
  specific language governing permissions and limitations
  under the License.
 --%>
+<!DOCTYPE html>
+<%@page import="java.util.List"%>
 <%@page import="org.apache.commons.jcs3.JCS"%>
 <%@page import="org.apache.commons.jcs3.access.CacheAccess" %>
 <%@page import="org.apache.commons.jcs3.admin.CacheElementInfo" %>
 <%@page import="org.apache.commons.jcs3.admin.CacheRegionInfo" %>
-<%@page import="java.io.Serializable" %>
-<%@page import="java.util.HashMap" %>
+<%@page import="org.apache.commons.jcs3.engine.behavior.ICacheElement" %>
 
 <jsp:useBean id="jcsBean" scope="request" class="org.apache.commons.jcs3.admin.JCSAdminBean" />
 
-<html>
+<html lang="en">
 <head>
-
-<SCRIPT LANGUAGE="Javascript">
-  function decision( message, url )
+  <script>
+  function decision(message, url)
   {
-    if( confirm(message) )
+    if(confirm(message))
     {
       location.href = url;
     }
   }
-</SCRIPT>
+  </script>
+  <style>
+  body {
+    font-family: Arial, Helvetica, sans-serif;
+    font-size: small;
+  }
+  
+  h1 {
+    font-size: large;
+    color: navy;
+  }
 
-<title> JCS Admin Servlet </title>
+  h2 {
+    font-size: medium;
+    color: navy;
+  }
 
+  a {
+    color: navy;
+    font-weight: 700;
+    text-decoration: none;
+  }
+
+  /* Change color on hover */
+  a:hover {
+    background-color: navy;
+    color: white;
+  }
+  
+  pre {
+    font-size: medium;
+  }
+  
+  table, th, td {
+    border: thin solid #a0a0a0;
+    font-size: small;
+  }
+  
+  table {
+    border-collapse: collapse;
+  }
+  
+  tr:nth-child(odd) {
+    background: #EEE;
+  }
+
+  th, td {
+    padding: 4pt;
+  }
+  
+  th {
+    background-color: navy;
+    color: white;
+    font-weight: 700;
+    text-align: left;
+  }  
+  </style>
+  <title>JCS Administration</title>
 </head>
-
 <body>
-
 <%
-			String CACHE_NAME_PARAM = "cacheName";
-			String ACTION_PARAM = "action";
-		 	String CLEAR_ALL_REGIONS_ACTION = "clearAllRegions";
-		 	String CLEAR_REGION_ACTION = "clearRegion";
-		 	String REMOVE_ACTION = "remove";
-		 	String DETAIL_ACTION = "detail";
-		 	String REGION_SUMMARY_ACTION = "regionSummary";
-		 	String ITEM_ACTION = "item";
-			String KEY_PARAM = "key";
-			String SILENT_PARAM = "silent";
+	final String CACHE_NAME_PARAM = "cacheName";
+    final String ACTION_PARAM = "action";
+    final String CLEAR_ALL_REGIONS_ACTION = "clearAllRegions";
+    final String CLEAR_REGION_ACTION = "clearRegion";
+    final String REMOVE_ACTION = "remove";
+    final String DETAIL_ACTION = "detail";
+    final String REGION_SUMMARY_ACTION = "regionSummary";
+    final String ITEM_ACTION = "item";
+    final String KEY_PARAM = "key";
 
-     		String DEFAULT_TEMPLATE_NAME = "DEFAULT";
-     		String REGION_DETAIL_TEMPLATE_NAME = "DETAIL";
-     		String ITEM_TEMPLATE_NAME = "ITEM";
-     		String REGION_SUMMARY_TEMPLATE_NAME = "SUMMARY";
+    final String DEFAULT_TEMPLATE_NAME = "DEFAULT";
+    final String REGION_DETAIL_TEMPLATE_NAME = "DETAIL";
+    final String ITEM_TEMPLATE_NAME = "ITEM";
+    final String REGION_SUMMARY_TEMPLATE_NAME = "SUMMARY";
 
-			String templateName = DEFAULT_TEMPLATE_NAME;
+	String templateName = DEFAULT_TEMPLATE_NAME;
 
-			HashMap<String, Object> context = new HashMap<String, Object>();
+	// Get cacheName for actions from request (might be null)
+	String cacheName = request.getParameter(CACHE_NAME_PARAM);
 
-			// Get cacheName for actions from request (might be null)
-			String cacheName = request.getParameter( CACHE_NAME_PARAM );
+	if (cacheName != null)
+	{
+	    cacheName = cacheName.trim();
+	}
 
-			if ( cacheName != null )
-			{
-			    cacheName = cacheName.trim();
-			}
+	// If an action was provided, handle it
+	String action = request.getParameter(ACTION_PARAM);
 
-			// If an action was provided, handle it
-			String action = request.getParameter( ACTION_PARAM );
+	if (action == null)
+	{
+	    // do nothing
+	}
+	else if (action.equals(CLEAR_ALL_REGIONS_ACTION))
+	{
+		jcsBean.clearAllRegions();
+	}
+	else if (action.equals(CLEAR_REGION_ACTION) && cacheName != null)
+	{
+		jcsBean.clearRegion(cacheName);
+	}
+	else if (action.equals(REMOVE_ACTION))
+	{
+		for (String key : request.getParameterValues(KEY_PARAM))
+		{
+			jcsBean.removeItem(cacheName, key);
+		}
 
-			if ( action != null )
-			{
-				if ( action.equals( CLEAR_ALL_REGIONS_ACTION ) )
-				{
-					jcsBean.clearAllRegions();
-				}
-				else if ( action.equals( CLEAR_REGION_ACTION ) )
-				{
-					if ( cacheName == null )
-					{
-						// Not Allowed
-					}
-					else
-					{
-						jcsBean.clearRegion( cacheName );
-					}
-				}
-				else if ( action.equals( REMOVE_ACTION ) )
-				{
-					String[] keys = request.getParameterValues( KEY_PARAM );
+		templateName = REGION_DETAIL_TEMPLATE_NAME;
+	}
+	else if (action.equals(DETAIL_ACTION))
+	{
+		templateName = REGION_DETAIL_TEMPLATE_NAME;
+	}
+	else if (action.equals(ITEM_ACTION))
+	{
+		templateName = ITEM_TEMPLATE_NAME;
+	}
+	else if (action.equals(REGION_SUMMARY_ACTION))
+	{
+		templateName = REGION_SUMMARY_TEMPLATE_NAME;
+	}
 
-					for ( int i = 0; i < keys.length; i++ )
-					{
-						jcsBean.removeItem( cacheName, keys[ i ] );
-					}
+    ///////////////////////////////////////////////////////////////////////////////////
+	//handle display
 
-					templateName = REGION_DETAIL_TEMPLATE_NAME;
-				}
-				else if ( action.equals( DETAIL_ACTION ) )
-				{
-					templateName = REGION_DETAIL_TEMPLATE_NAME;
-				}
-				else if ( action.equals( ITEM_ACTION ) )
-				{
-					templateName = ITEM_TEMPLATE_NAME;
-				}
-				else if ( action.equals( REGION_SUMMARY_ACTION ) )
-				{
-					templateName = REGION_SUMMARY_TEMPLATE_NAME;
-				}
-			}
+	if (templateName == ITEM_TEMPLATE_NAME)
+	{
+	    String key = request.getParameter(KEY_PARAM);
 
-			if ( request.getParameter( SILENT_PARAM ) != null )
-			{
-				// If silent parameter was passed, no output should be produced.
-				//return null;
-			}
-			else
-			{
-				// Populate the context based on the template
-				if ( templateName == REGION_DETAIL_TEMPLATE_NAME )
-				{
-					//context.put( "cacheName", cacheName );
-					context.put( "elementInfoRecords", jcsBean.buildElementInfo( cacheName ) );
-				}
-				else if ( templateName == DEFAULT_TEMPLATE_NAME )
-				{
-					context.put( "cacheInfoRecords", jcsBean.buildCacheInfo() );
-				}
-			}
+	    if (key != null)
+	    {
+	        key = key.trim();
+	    }
 
-///////////////////////////////////////////////////////////////////////////////////
-			//handle display
-
-			if ( templateName == ITEM_TEMPLATE_NAME )
-			{
-			    String key = request.getParameter( KEY_PARAM );
-
-			    if ( key != null )
-			    {
-			        key = key.trim();
-			    }
-
-			    CacheAccess<Serializable, Serializable> cache = JCS.getInstance( cacheName );
-				org.apache.commons.jcs3.engine.behavior.ICacheElement<?, ?> element = cache.getCacheElement( key );
+	    CacheAccess<Object, Object> cache = JCS.getInstance(cacheName);
+		ICacheElement<?, ?> element = cache.getCacheElement(key);
 %>
-<h1> Item for key [<%=key%>] in region [<%=cacheName%>] </h1>
-
-<a href="JCSAdmin.jsp?action=detail&cacheName=<%=cacheName%>">Region Detail</a>
-| <a href="JCSAdmin.jsp">All Regions</a>
-
-  <pre>
-	<%=element%>
-  </pre>
+<h1>Item for key [<%=key%>] in region [<%=cacheName%>]</h1>
+<p><a href="?action=detail&cacheName=<%=cacheName%>">Region Detail</a>
+| <a href="?">All Regions</a></p>
+<pre>
+<%=element%>
+</pre>
 <%
-			}
-			else if ( templateName == REGION_SUMMARY_TEMPLATE_NAME )
-			{
+	}
+	else if (templateName == REGION_SUMMARY_TEMPLATE_NAME)
+	{
 %>
-
-<h1> Summary for region [<%=cacheName%>] </h1>
-
-<a href="JCSAdmin.jsp">All Regions</a>
-
+<h1>Summary for region [<%=cacheName%>]</h1>
+<p><a href="?">All Regions</a></p>
 <%
-    CacheAccess<?, ?> cache = JCS.getInstance( cacheName );
-    String stats = cache.getStats();
+        CacheAccess<?, ?> cache = JCS.getInstance(cacheName);
+        String stats = cache.getStats();
 %>
-
-    <br>
-<b> Stats for region [<%=cacheName%>] </b>
-
-    <pre>
-    	<%=stats%>
-    </pre>
-
+<h2>Statistics for region [<%=cacheName%>]</h2>
+<pre>
+<%=stats%>
+</pre>
 <%
-			}
-			else if ( templateName == REGION_DETAIL_TEMPLATE_NAME )
-			{
+	}
+	else if (templateName == REGION_DETAIL_TEMPLATE_NAME)
+	{
 %>
-
-<h1> Detail for region [<%=cacheName%>] </h1>
-
-<a href="JCSAdmin.jsp">All Regions</a>
-
-<table border="1" cellpadding="5" >
-    <tr>
-        <th> Key </th>
-        <th> Eternal? </th>
-        <th> Create time </th>
-        <th> Max Life (s) </th>
-        <th> Till Expiration (s) </th>
-    </tr>
+<h1>Detail for region [<%=cacheName%>]</h1>
+<p><a href="?">All Regions</a></p>
+<table>
+  <tr>
+    <th>Key</th>
+    <th>Eternal?</th>
+    <th>Create time</th>
+    <th>Max Life (s)</th>
+    <th>Till Expiration (s)</th>
+  </tr>
 <%
-	CacheElementInfo[] list = (CacheElementInfo[]) context.get( "elementInfoRecords" );
-    for (CacheElementInfo element : list)
-    {
+        for (CacheElementInfo element : jcsBean.buildElementInfo(cacheName))
+        {
 %>
-        <tr>
-            <td> <%=element.getKey()%> </td>
-            <td> <%=element.isEternal()%> </td>
-            <td> <%=element.getCreateTime()%> </td>
-            <td> <%=element.getMaxLifeSeconds()%> </td>
-            <td> <%=element.getExpiresInSeconds()%> </td>
-            <td>
-             <a href="JCSAdmin.jsp?action=item&cacheName=<%=cacheName%>&key=<%=element.getKey()%>"> View </a>
-            | <a href="JCSAdmin.jsp?action=remove&cacheName=<%=cacheName%>&key=<%=element.getKey()%>"> Remove </a>
-            </td>
-        </tr>
+  <tr>
+    <td><%=element.getKey()%></td>
+    <td><%=element.isEternal()%></td>
+    <td><%=element.getCreateTime()%></td>
+    <td><%=element.getMaxLifeSeconds()%></td>
+    <td><%=element.getExpiresInSeconds()%></td>
+    <td>
+      <a href="?action=item&cacheName=<%=cacheName%>&key=<%=element.getKey()%>"> View </a>
+      | <a href="?action=remove&cacheName=<%=cacheName%>&key=<%=element.getKey()%>"> Remove </a>
+    </td>
+  </tr>
+<%
+        }
+
+        CacheAccess<?, ?> cache = JCS.getInstance(cacheName);
+        String stats = cache.getStats();
+%>
+</table>
+<h2>Statistics for region [<%=cacheName%>]</h2>
+<pre>
+<%=stats%>
+</pre>
 <%
     }
-
-    CacheAccess<?, ?> cache = JCS.getInstance( cacheName );
-    String stats = cache.getStats();
+    else
+    {
 %>
-    </table>
-
-    <br>
-<b> Stats for region [<%=cacheName%>] </b>
-
-    <pre>
-    	<%=stats%>
-    </pre>
-<%
-  }
-  else
-  {
-%>
-
-<h1> Cache Regions </h1>
-
+<h1>Cache Regions</h1>
 <p>
 These are the regions which are currently defined in the cache. 'Items' and
 'Bytes' refer to the elements currently in memory (not spooled). You can clear
-all items for a region by selecting 'Remove all' next to the desired region
-below. You can also <a href="javascript:decision('Clicking OK will clear all the data from all regions!','JCSAdmin.jsp?action=clearAllRegions')">Clear all regions</a>
+all items for a region by selecting 'Clear' next to the desired region
+below. You can also <a href="javascript:decision('Clicking OK will clear all the data from all regions!','?action=clearAllRegions')">Clear all regions</a>
 which empties the entire cache.
 </p>
-<p>
-	<form action="JCSAdmin.jsp">
-		<input type="hidden" name="action" value="item">
-		Retrieve (key) <input type="text" name="key"> &nbsp;
-		(region) <select name="cacheName">
+<form action="?"><p>
+  <input type="hidden" name="action" value="item" />
+  Retrieve <input type="text" name="key" autofocus="autofocus" placeholder="(key)" /> 
+  from region <select name="cacheName">
 <%
-  CacheRegionInfo[] listSelect = (CacheRegionInfo[]) context.get( "cacheInfoRecords" );
-  for (CacheRegionInfo record : listSelect)
-  {
-	%>
+        List<CacheRegionInfo> records = jcsBean.buildCacheInfo();
+
+        for (CacheRegionInfo record : records)
+        {
+%>
     <option value="<%=record.getCacheName()%>"><%=record.getCacheName()%></option>
-	<%
-  }
-%>
-				</select>
-		<input type="submit">
-	</form>
-</p>
-
-<table border="1" cellpadding="5" >
-    <tr>
-        <th> Cache Name </th>
-        <th> Items </th>
-        <th> Bytes </th>
-        <th> Status </th>
-        <th> Memory Hits </th>
-        <th> Aux Hits </th>
-        <th> Not Found Misses </th>
-        <th> Expired Misses </th>
-    </tr>
-
 <%
-	CacheRegionInfo[] list = (CacheRegionInfo[]) context.get( "cacheInfoRecords" );
-    for (CacheRegionInfo record : listSelect)
-    {
+        }
 %>
-        <tr>
-            <td> <%=record.getCacheName()%> </td>
-            <td> <%=record.getCacheSize()%> </td>
-            <td> <%=record.getByteCount()%> </td>
-            <td> <%=record.getCacheStatus()%> </td>
-            <td> <%=record.getHitCountRam()%> </td>
-            <td> <%=record.getHitCountAux()%> </td>
-            <td> <%=record.getMissCountNotFound()%> </td>
-            <td> <%=record.getMissCountExpired()%> </td>
-            <td>
-                <a href="JCSAdmin.jsp?action=regionSummary&cacheName=<%=record.getCacheName()%>"> Summary </a>
-                | <a href="JCSAdmin.jsp?action=detail&cacheName=<%=record.getCacheName()%>"> Detail </a>
-                | <a href="javascript:decision('Clicking OK will remove all the data from the region [<%=record.getCacheName()%>]!','JCSAdmin.jsp?action=clearRegion&cacheName=<%=record.getCacheName()%>')"> Clear </a>
-            </td>
-        </tr>
+  </select>
+  <input type="submit" value="Retrieve" />
+</p></form>
+<table>
+  <tr>
+    <th>Cache Name</th>
+    <th>Items</th>
+    <th>Bytes</th>
+    <th>Status</th>
+    <th>Memory Hits</th>
+    <th>Aux Hits</th>
+    <th>Not Found Misses</th>
+    <th>Expired Misses</th>
+    <th>Actions</th>
+  </tr>
+<%
+        for (CacheRegionInfo record : records)
+        {
+%>
+  <tr>
+    <td><%=record.getCacheName()%></td>
+    <td><%=record.getCacheSize()%></td>
+    <td><%=record.getByteCount()%></td>
+    <td><%=record.getCacheStatus()%></td>
+    <td><%=record.getHitCountRam()%></td>
+    <td><%=record.getHitCountAux()%></td>
+    <td><%=record.getMissCountNotFound()%></td>
+    <td><%=record.getMissCountExpired()%></td>
+    <td>
+      <a href="?action=regionSummary&cacheName=<%=record.getCacheName()%>">Summary</a>
+      | <a href="?action=detail&cacheName=<%=record.getCacheName()%>">Detail</a>
+      | <a href="javascript:decision('Clicking OK will remove all the data from the region [<%=record.getCacheName()%>]!','?action=clearRegion&cacheName=<%=record.getCacheName()%>')">Clear</a>
+    </td>
+  </tr>
+<%
+        }
+%>
+</table>
 <%
     }
 %>
-    </table>
-<%
-  }
-%>
-
-
 </body>
-
 </html>