jsp高手看进来 给分啦 ! 判断是否为数字 返回添加成功!
我做了添加数据的页面! 代码如下
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*"
errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<jsp:useBean id="con" scope="page" class="bean.Connect"/>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>添加部门</title>
<Script language="javascript">
function check()
{
if(document.form1.id.value=="")
{
alert("请填写部门编号!");
document.form1.id.focus();
return;
}
if(document.form1.name.value=="")
{
alert("请填写部门名称!");
document.form1.name.focus();
return;
}
if(document.form1.depm.value=="")
{
alert("请填写部门负责人!");
document.form1.depm.focus();
return;
}
/* var val=document.form1.ph.value;
var len=val.length;
if(len>0)
{
for(j=0;j<len;j++)
{
var str=val.substring(j,j+1);
if(str<"0"||str>"9")
{
alert("请输入数字");
break;
}
}
}*/
document.form1.submit();
}
</script>
<%!
String sql="";
String id="";
String name="";
String depch="";
String ph1="";
int ph=0;
%>
</head>
<body bgcolor="#D2E4FC" >
<br><br><br>
<form action="depadd.jsp" name="form1">
<div align="center"><table>
<tr><td align="left">部门编号:</td><td><input type="text" name="id" /></td></tr>
<tr><td align="left">部门名称:</td><td><input type="text" name="name" /></td></tr>
<tr><td align="left">负 责 人:</td><td><input type="text" name="depm" /></td></tr>
<tr><td align="left">联系电话:</td><td><input type="text" name="ph" /></td></tr>
</table>
<p> </p>
<p>
<input type="button" name="add" value=" 添加部门 " onclick="check()"> <input type="button" name="add" value=" 返回浏览查询 " onclick="window.location.href='department.jsp'">
</p>
</div>
</form>
<%
id=request.getParameter("id");
name=request.getParameter("name");
depch=request.getParameter("depm");
ph1=request.getParameter("ph");
ph=Integer.parseInt(ph1);
sql="insert into dept values("+id+","+name+","+depch+","+ph+")";
con.executeInsert(sql);
%>
</body>
</html>
报以下的错误
org.apache.jasper.JasperException: An exception occurred processing JSP page /admin/depadd.jsp at line 79
76: name=request.getParameter("name");
77: depch=request.getParameter("depm");
78: ph1=request