Hello I still have a problem, I can't display any data in jsp page, as you can see in the code i have imported the java class into jsp and created an object of the class and called the method for output from java class but it seems something wrong ..help please. (please explain your advice because some hint are harder to understand - thanks)
package mydata;
import org.hyperic.sigar.CpuInfo;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
public class test {
public test() {
Sigar sigar = new Sigar();
String output = " ";
CpuInfo[] cpuInfoList = null;
try {
cpuInfoList = sigar.getCpuInfoList();
} catch (SigarException e) {
e.printStackTrace();
return;
}
for (CpuInfo info : cpuInfoList) {
output += "\nCPU\n";
output += "Vendor: " + info.getVendor() + "\n";
output += "Clock: " + info.getMhz() + "Mhz\n";
output += "Core: " + info.getCoresPerSocket();
}
System.out.println(output);
}
public static void main(String[] args) {
test main = new test();
}
}
//JSP Code
<%@page import="mydata.test"%>
<%@page import="org.hyperic.sigar.Sigar"%>
<%@page import="org.hyperic.sigar.CpuInfo"%>
<%@page import="org.hyperic.sigar.SigarException"%>
<%@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>
<h1>Welcome to data page</h1>
<%@ page import="mydata.test.*"%>
<%
String output="";
CpuInfo[] cpuInfoList = null;
test ts = new test();
Sigar sigar = new Sigar();
out.println(output);
out.println(sigar.getCpuInfoList());
%>
</body>
</html>