JSP员工信息添加页面:add_employee.jsp

JSP员工信息添加页面:add_employee.jsp

<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%
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>

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值