JWS-121 & JWS-111 Adding ‘timestamp’ (string formatted date + time) to the HttpServ...
authorFábio Madeira <fmmarquesmadeira@dundee.ac.uk>
Wed, 31 May 2017 16:01:22 +0000 (17:01 +0100)
committerFábio Madeira <fmmarquesmadeira@dundee.ac.uk>
Wed, 31 May 2017 16:01:22 +0000 (17:01 +0100)
webservices/compbio/stat/servlet/AnnualStat.java
webservices/compbio/stat/servlet/ServiceStatus.java
website/statpages/MonthlySummary.jsp
website/statpages/ServicesStatus.jsp

index 26150de..eead7a5 100644 (file)
@@ -22,6 +22,8 @@ import java.io.PrintWriter;
 import java.sql.SQLException;\r
 import java.util.Date;\r
 import java.util.Map;\r
+import java.util.Calendar;\r
+import java.text.SimpleDateFormat;\r
 \r
 import javax.servlet.RequestDispatcher;\r
 import javax.servlet.ServletException;\r
@@ -55,7 +57,11 @@ public class AnnualStat extends HttpServlet {
                        long endTime = System.nanoTime();\r
                        req.setAttribute("stat", monthlyTotals);\r
                        req.setAttribute("total", Totals.sumOfTotals(monthlyTotals));\r
-                       req.setAttribute("timeexec", (endTime - startTime) / 1000000);\r
+//                     req.setAttribute("timeexec", (endTime - startTime) / 1000000);\r
+                       req.setAttribute("timeexec", (endTime - startTime) / 100000000);\r
+                       String timeStamp = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(\r
+                               Calendar.getInstance().getTime());\r
+                       req.setAttribute("timestamp", timeStamp);\r
 \r
                        RequestDispatcher dispatcher = req.getRequestDispatcher("statpages/MonthlySummary.jsp");\r
 \r
index 93df9f5..0b82be9 100644 (file)
@@ -29,7 +29,8 @@ import java.util.ArrayList;
 import java.util.Iterator;\r
 import java.util.List;\r
 import java.util.Set;\r
-import java.util.Collections;\r
+import java.util.Calendar;\r
+import java.text.SimpleDateFormat;\r
 \r
 import javax.management.AttributeNotFoundException;\r
 import javax.management.InstanceNotFoundException;\r
@@ -148,7 +149,11 @@ public class ServiceStatus extends HttpServlet {
                }\r
                req.setAttribute("results", testResults);\r
                long endTime = System.nanoTime();\r
-               req.setAttribute("timeexec", (endTime - startTime) / 1000000);\r
+//             req.setAttribute("timeexec", (endTime - startTime) / 1000000);\r
+               req.setAttribute("timeexec", (endTime - startTime) / 100000000);\r
+               String timeStamp = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(\r
+                               Calendar.getInstance().getTime());\r
+               req.setAttribute("timestamp", timeStamp);\r
                RequestDispatcher rd = req.getRequestDispatcher("statpages/ServicesStatus.jsp");\r
                rd.forward(req, resp);\r
        }\r
index a1f0090..382642d 100644 (file)
@@ -22,10 +22,13 @@ Date: May 2011
                        <div class="panel-body">
                                <div style="margin: 20px ">
                                        <ul>
-                                               <li>Server: <a href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}">
+                                               <li><strong>Server:</strong> <a href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}">
                                                        ${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}
                                                </a> </li>
-                                               <li>Time of execusion: ${timeexec} msec</li>
+                                               <li><strong>Time of execution:</strong> ${timeexec} sec</li>
+                                               <li><strong>Usage Statistics as of:</strong> ${timestamp}</li>
+                                               <li><a href="${pageContext.request.contextPath}/PublicAnnualStat" title="JABAWS server usage statistics."
+                                               id="show_hidden2"><i class="fa fa-bar-chart" aria-hidden="true"></i> Refresh Usage Statistics</a></li>
                                        </ul>
                                        <br/>
                                        <table class="center its" style="width: 600px ">
index 27b622e..7c0fa76 100644 (file)
@@ -34,12 +34,15 @@ TODO refactor
                                                        This servlet tests if the web services are healthy on the tomcat instance on which JABAWS is deployed. <br/>
                                                        If the tomcat instance is mapped to another "proxy" web server, the servlet does not test availability of <br/>
                                                        the web services at the endpoints of this external web server.</li>
-                                               <li>All the web services are tested while this page is being loaded.</li>
-                                               <li>If you want to test the services again, reload this page.</li>
+                                               <%--<li>All the web services are tested while this page is being loaded.</li>--%>
+                                               <%--<li>If you want to test the services again, reload this page.</li>--%>
                                                <li>Click on the service status to see the results of the testing.</li>
-                                               <li>Server tested: <a href="${host}">${host}</a> </li>
-                                               <li>Time of execusion: ${timeexec} msec</li>
-                                               <li> Your IP is ${pageContext.request.remoteAddr}</li>
+                                               <li><strong>Server:</strong> <a href="${host}">${host}</a> </li>
+                                               <li><strong>Time of execution:</strong> ${timeexec} sec</li>
+                                               <li><strong>Service Status as of:</strong> ${timestamp}</li>
+                                               <li><a href="${pageContext.request.contextPath}/ServiceStatus" title="JABAWS web-services status."
+                                                  id="show_hidden1"><i class="fa fa-cogs" aria-hidden="true"></i> Refresh Service Status</a></li>
+                                               <%--<li> Your IP is ${pageContext.request.remoteAddr}</li>--%>
                                        </ul>
                                        <br/>
                                        <h3 style="text-align: center;color: green">