read_Jxl.jsp
<%@ page language="java" import="java.lang.*,java.util.*,java.io.*,jxl.*,jxl.format.*,jxl.write.*"%>
<%@ page contentType="text/html; charset=gb2312"%>
<%
//Workbook book= Workbook.getWorkbook(new File("chenyubo.xls"));
Workbook book =Workbook.getWorkbook(new File("IP.xls"));
int sheets = book.getNumberOfSheets();
for(int t=0;t<sheets;t++){
Sheet sheet =book.getSheet(t);
String sheetName = sheet.getName();
int rsColumns = sheet.getColumns();
out.println(sheetName+"<br><br><br>");
int Rows = sheet.getRows();
for(int i=0;i<Rows;i++){
Cell cell7 =sheet.getCell(7,i);
String name7 =cell7.getContents();
if(name7.equals(""))
name7="未占用";
Cell cell8 =sheet.getCell(8,i);
String name8 =cell8.getContents();
Cell cell9 =sheet.getCell(9,i);
String name9 =cell9.getContents();
out.println(name7+"------<a href=test_ping.jsp?ip="+name8+">"+name8+"</a>------"+name9+"<br>");
}
}
%>
test_ping.jsp
<%@ page language="java" contentType="text/html; charset=gb2312" import="java.io.*,java.util.*,java.text.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Ping IP测试页面</title>
</head>
<body>
<div align="center">
<h2>Ping IP测试页面</h2>
</div>
<%
String ip =request.getParameter("ip");
Runtime runtime = Runtime.getRuntime();
Process process =null;
String line=null;
InputStream is =null;
InputStreamReader isr=null;
BufferedReader br =null;
try {
process =runtime.exec("ping "+ip);
is = process.getInputStream();
isr=new InputStreamReader(is);
br =new BufferedReader(isr);
out.println("<pre>");
while( (line = br.readLine()) != null )
{
out.println(line);
out.flush();
}
}catch (Exception e)
{
e.printStackTrace();
System.out.println(e.toString());
}
%>
</body>
</html>