<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<jsp:include page="check.jsp" flush="true" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>www.xin126.cn原创 'add_employee.jsp' </title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="jsp,信息添加">
<meta http-equiv="description" content="www.xin126.cn原创教程:JSP员工信息添加页面:add_employee.jsp">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body> <form name="form1" method="post" action="add_ok.jsp">
<table width="300" border="0" align="center" cellpadding="0" cellspacing="10">
<tr>
<td width="92"><a href="javascript:history.go(-1)" >返回上一页</a></td>
<td width="178">员工信息添加页面</td>
</tr>
</table>
<table width="543" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td width="185" height="23">员工姓名:<br></td>
<td width="353"><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td>出生日期:</td>
<td>
<input name="birthday" type="text" id="birthday">
(格式 1981-01-01)
</td>
</tr>
<tr>
<td>薪 水:</td>
<td>
<input name="salary" type="text" id="salary">
</td>
</tr>
<tr>
<td>
<input type="submit" name="Submit" value="添加" >
</td>
<td>
<input type="reset" name="Submit2" value="清空">
</td>
</tr>
</table>
</form>
</body>
</html>
add_ok.jsp页面代码:
<%@ page language="java" import="java.sql.*" 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>www.xin126.cn原创教程 'add_ok.jsp'</title>
</head>
<body><center>
<%request.setCharacterEncoding("gb2312");
String name=request.getParameter("name");
String birthday=request.getParameter("birthday");
String salary=request.getParameter("salary");
Connection con;
Statement sql;
try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{ out.print(e);
}
try { con=DriverManager.getConnection("jdbc:odbc:employee_dsn","sa","2005");
sql=con.createStatement();
int m=sql.executeUpdate("insert into employee_info(employee_name,birthday,salary) values('"+name+"','"+birthday+"',"+salary+")");
if(m!=0)
{
out.print(m+"条记录添加成功!");}
else{out.print("添加失败!");}
con.close();
}
catch(SQLException e)
{ out.print(e);
}
%><p ><a href="add_employee.jsp">继续添加</a> <a href="admin.jsp" >返回首页</a></p></center>
</body>
</html>