Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Refresh and stop refreshing jsp content

843840Jul 1 2008 — edited Jul 2 2008
Hi, i'm trying to write a web app using jsp. It basically mines data from the glassfish log file and reports the perfomance analysis of a web service.

There are two main operations: the first takes in input two dates, and reports the performance analysis in that date interval.

The second should do a real time analysis, with a start and stop button. Here is the code:


index.jsp

<%@page contentType="text/html" 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>JSP Page</title>
    </head>
    <body>
        <center><img src="inspector.jpg"><br>
    <table><td><tr><form name="datamining" method="POST" >
        <INPUT TYPE="HIDDEN" NAME="realtime" 
   VALUE="no">
        <input type="text" name="date1" value="yyyy-MM-dd-HH:mm:ss" />
         <input type="text" name="date2" value="yyyy-MM-dd-HH:mm:ss" />
         <input type="submit" value="inspect" name="submit" />
 </form></tr>
<tr><form name="real Time" method="POST">
<INPUT TYPE="HIDDEN" NAME="realtime" VALUE="yes">    
<input type="submit" value="Start" name="submit" />
</form></tr>
</td></table></center>
<%@ include file="result.jsp" %>

        
    </body>
</html>
result. jsp
<%@page contentType="text/html" pageEncoding="UTF-8" import="inspector.Inspector"%>
<!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>JSP Page</title>
   
        <% 
        if(request.getParameter("realtime")!=null) {
        if(request.getParameter("realtime").equals("no")) {
        String date1 = request.getParameter("date1");
        String date2 = request.getParameter("date2");
        Inspector rest = new Inspector(date1, date2, true);
        Inspector soap = new Inspector(date1, date2, false);
        out.println(" </head><body><table><td>");
        out.println("<h3>REST</h3><br>");
        out.println("<ul><li>Richieste totali: "+rest.getTotalRequests()+"</li>");
        out.println("<li>Tempo medio di processazione: "+rest.getaverageProcessTime()+" ms</li>");
        out.println("<li>Tempo massimo di processazione: "+rest.getMaxProcessTime()+" ms</li>");
        out.println("<li>Tempo minimo di processazione: "+rest.getMinProcessTime()+" ms</li></ul></td>");
        out.println("<td><h3>SOAP</h3><br>");
        out.println("<ul><li>Richieste totali: "+soap.getTotalRequests()+"</li>");
        out.println("<li>Tempo medio di processazione: "+soap.getaverageProcessTime()+" ms</li>");
        out.println("<li>Tempo massimo di processazione: "+soap.getMaxProcessTime()+" ms</li>");
        out.println("<li>Tempo minimo di processazione: "+soap.getMinProcessTime()+" ms</li></ul></td>");
        
        } 
        else if(request.getParameter("realtime").equals("yes")) {
            Inspector rest = new Inspector(true);
            Inspector soap = new Inspector(false);
            out.println("<meta http-equiv=\"refresh\" content=\"1\"></head><body>");
            out.println("<table><td>");
        out.println("<h3>REST</h3><br>");
        out.println("<ul><li>Richieste totali: "+rest.getTotalRequests()+"</li>");
        out.println("<li>Tempo medio di processazione: "+rest.getaverageProcessTime()+" ms</li>");
        out.println("<li>Tempo massimo di processazione: "+rest.getMaxProcessTime()+" ms</li>");
        out.println("<li>Tempo minimo di processazione: "+rest.getMinProcessTime()+" ms</li></ul></td>");
        out.println("<td><h3>SOAP</h3><br>");
        out.println("<ul><li>Richieste totali: "+soap.getTotalRequests()+"</li>");
        out.println("<li>Tempo medio di processazione: "+soap.getaverageProcessTime()+" ms</li>");
        out.println("<li>Tempo massimo di processazione: "+soap.getMaxProcessTime()+" ms</li>");
        out.println("<li>Tempo minimo di processazione: "+soap.getMinProcessTime()+" ms</li></ul></td>");
            
        }
     }
    %>    
        
    </body>
</html>
basically, creating an Inspector object without date automatically invokes a method that refreshes every 2 seconds the log file and reports the service sessions.

The stop button is still not implemented, first I need to know how can I refresh the page content. At first I tried with meta-refresh, but in facts it just refreshes the HTML code, and not the java code.

Any Ideas?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 30 2008
Added on Jul 1 2008
3 comments
1,246 views