table real-time refresh problem?

12 views
Skip to first unread message

china_shi

unread,
May 6, 2010, 1:26:22 AM5/6/10
to Jaxcent
A table have 300 records, The data refresh by one second . CPU
occupancy rate reaches to 20%,if I open several the IE pages then CPU
occupancy rate will reach to 90%,WHY????????????????

the code follows:
1、JaxcentSampleConfig.xml
<Page>
<PagePath>/testjaxcent/testMyselfTable.jsp</PagePath>
<PageClass>sample.TestMyselfTableSample</PageClass>
</Page>
2、web.xml
<servlet>
<servlet-name>JaxcentServlet</servlet-name>
<servlet-class>jaxcentServlet.JaxcentServlet</servlet-class>
<init-param>
<param-name>JaxcentConfigXML</param-name>
<param-value>/WEB-INF/JaxcentSampleConfig.xml</param-
value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>JaxcentServlet</servlet-name>
<url-pattern>/servlet/JaxcentServlet21/*</url-pattern>
</servlet-mapping>
3、jsp page
<%@ page language="java" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()
+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>real-time refresh</title>
<SCRIPT TYPE="text/javascript" SRC="<%=basePath%>/
jaxcenttest21.js"></SCRIPT>
</head>
<body>
<TABLE id="widgetsTable" BORDER=2 BGCOLOR="#D0D0D0">
<TR>
<TH>
&nbsp
</TH>
<TH>
Section 1
</TH>
<TH>
Section 2
</TH>
<TH>
Section 3
</TH>
<TH>
Section 4
</TH>
<TH>
Section 5
</TH>
<TH>
Section 6
</TH>
<TH>
Section 7
</TH>
<TH>
Section 8
</TH>
</TR>
<TR>
<TD>
Total
</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
.................................................................
.................................................................
.................................................................
.................................................................
<TR>
<TD>
Total
</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
</TABLE>
</body>
</html>
4、servlet code
package sample;

import java.text.DecimalFormat;

import jaxcent.*;

/**
* Jaxcent sample.
*
* Displays some simulated production counts in a table. The table
* is identified by an ID "widgetsTable".
*/

public class TestMyselfTableSample2 extends jaxcent.JaxcentPage {

static final int NSECTIONS = 8;

// The TABLE
HtmlTable table = new HtmlTable( this, "widgetsTable" );

// The timer thread for generating simulated data. In a real-life
situation,
// the data may be arriving from other sources asynchronously,
instead
// of from a timer!

Thread timerThread = null;

boolean running = false;

// Objects of interest on the page.
HtmlTableCell[][] tableCells = new HtmlTableCell[60][];

// We initialize the table cells in the constructor.

// Note: If there are any constructors specified for a JaxcentPage-
derived
// handler, there must be a public no-arg constructor.

public TestMyselfTableSample2()
{
try {

// Initialize the table cells array.

for ( int i = 0; i < 60; i++ ) {
tableCells[i] = new HtmlTableCell[NSECTIONS];
HtmlTableRow row = table.getRow( 1+i );
// The "1+i" is because of the header row.

for ( int j = 0; j < NSECTIONS; j++ ){
tableCells[i][j] = row.getCell( 1+j );
//
System.out.println( "sddddddddddddddddddddddddd"+row.getCell( 1+j ).getAlign());
}

}

// Start a timer for updates.

running = true;
timerThread = new Thread() {
public void run() {
simulateData();
}
};
timerThread.start();
} catch (Exception ex) {
ex.printStackTrace();
}
}

// Stop the thread on page unloading.

protected void onUnload()
{
running = false;
timerThread.interrupt();
}

// Data simulation
void simulateData()
{
while ( true ) {
DecimalFormat df = new DecimalFormat("0.0000");
// Fill the table.
try {
for ( int i = 0; i < NSECTIONS; i++ ) {
for ( int j = 0; j < 60; j++ ) {
tableCells[j]
[i].setInnerText(df.format(Math.random()));
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
try {
Thread.sleep( 1000 );
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}

--
You received this message because you are subscribed to the Google Groups "Jaxcent" group.
To post to this group, send email to jaxcen...@googlegroups.com.
To unsubscribe from this group, send email to jaxcentgroup...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jaxcentgroup?hl=en.

Mukesh

unread,
May 6, 2010, 9:10:39 AM5/6/10
to Jaxcent
Does the CPU reach 90% on the client, or the server? If on client,
does the same thing happen with Firefox? If server, what server are
you using (IIS, Apache direct, Tomcat, Jaxcent directly?)

china_shi

unread,
May 10, 2010, 1:18:30 AM5/10/10
to Jaxcent
Does the CPU reach 90% on the client,No impact on the server. It is
normal with Firefox,not normal with IE.

> For more options, visit this group athttp://groups.google.com/group/jaxcentgroup?hl=en.- 隐藏被引用文字 -
>
> - 显示引用的文字 -

Mukesh

unread,
May 10, 2010, 12:15:57 PM5/10/10
to Jaxcent
What server are you running? IIS, or Apache directly, or Apache/
Tomcat, or Jaxcent directly?

There are two reports on the forum about the IIS connector sometimes
getting into some kind of a loop, so this could be the same problem
(anybody wanna take a shot at the IIS connector code?)
> ...
>
> read more >>- Hide quoted text -
>
> - Show quoted text -

china_shi

unread,
May 11, 2010, 10:22:01 PM5/11/10
to Jaxcent
I using Tomcat,now I wanna know that ajax and jaxcent which
performance is better.Theoretically jaxcent is concurrent,it's
efficiency should be higher.but my testing is that ajax better than
jaxcent cry..........................................
> ...
>
> 阅读更多 >>- 隐藏被引用文字 -
Reply all
Reply to author
Forward
0 new messages