<%@ page contentType="text/html;charset=GBK" %>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>验证IP结果</title>
</head>

<body>
<%
	String strIP = request.getParameter("IP");
	out.print(strIP+"<br>");

	if(strIP==null || strIP=="") {
		out.print("<br>IP为空");
		return;
	}
	
	String []arrayIP = strIP.split("\\.");
	if(arrayIP.length != 4) {
		out.print("<br>不对");
		return;
	}

	 for(int i=0; i<arrayIP.length; i++) {
		try {
			int n = Integer.parseInt(arrayIP[i]);
			if((i==0||i==3) && (n==0||n==255)){
				out.print("非法IP");
				return;
			}
			if(n<0 || n>255) {
				out.print("非法数字");
				return;
			}
		} catch(NumberFormatException e) {
			out.print("非数字字符");
			return;
		}
	}

	out.print("<br><font color='red'>验证通过</font>");
%>
</body>

</html>