Some new servlet code
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Thu, 31 Oct 2013 22:54:13 +0000 (22:54 +0000)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Thu, 31 Oct 2013 22:54:13 +0000 (22:54 +0000)
server/compbio/listeners/LogServlet.java [new file with mode: 0644]
website/LogQuery.jsp [new file with mode: 0644]
website/ReportLog.jsp [new file with mode: 0644]

diff --git a/server/compbio/listeners/LogServlet.java b/server/compbio/listeners/LogServlet.java
new file mode 100644 (file)
index 0000000..0f6d007
--- /dev/null
@@ -0,0 +1,43 @@
+package compbio.listeners;
+
+import java.io.IOException;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import compbio.statistic.StatisticsProt;
+
+/**
+ * Servlet implementation class LogServlet
+ */
+public class LogServlet extends HttpServlet {
+       private static final long serialVersionUID = 1L;
+       
+    
+
+       /**
+        * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+        */
+       protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+               final long startTime = System.currentTimeMillis();
+               String id = request.getParameter("IdJob");
+               StatisticsProt sp = new StatisticsProt();
+//             request.setAttribute("result", sp.readJobLog(id));
+               final long endTime = System.currentTimeMillis();
+               request.setAttribute("timeExecution", (endTime - startTime));
+               request.setAttribute("IdJob", id);
+               RequestDispatcher rd = request.getRequestDispatcher("/ReportLog.jsp");
+               rd.forward(request, response);
+       }
+
+       /**
+        * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+        */
+       protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+               doGet(request, response);
+       }
+
+}
diff --git a/website/LogQuery.jsp b/website/LogQuery.jsp
new file mode 100644 (file)
index 0000000..a14fb87
--- /dev/null
@@ -0,0 +1,17 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+    pageEncoding="UTF-8"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Log query</title>
+</head>
+<body>
+       <br/>
+       <form method="get" action="LogServlet">
+               <h3>Enter job ID</h3>   
+               <input type="text" name="IdJob"><br/>
+               <input type="submit" name="Search" value="Search"/><br/><br/>
+       </form>
+</body>
+</html>
\ No newline at end of file
diff --git a/website/ReportLog.jsp b/website/ReportLog.jsp
new file mode 100644 (file)
index 0000000..e3cc33e
--- /dev/null
@@ -0,0 +1,17 @@
+<%@page import="java.util.ArrayList"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
+<%@ taglib uri="http://displaytag.sf.net" prefix="dt" %>
+<h3>Jobs log information for: ${IdJob}</h3>
+<h3>Time execution: ${timeExecution} ms</h3>
+<c:forEach items="${result}" var="res">
+<p>${res.nameColumn} :
+${res.valueColumn}
+</p>
+</c:forEach>
+<c:forEach items="${result}" var="res">
+<p>${res.namePrediction} :
+${res.valuePrediction}
+</p>
+</c:forEach>
\ No newline at end of file