📄 welfareenrollapp.jsp
字号:
<%@ page language="java" %> <%-- 脚本所用语言 --%>
<%@ page contentType="text/html;charset=gb2312" %> <%-- 定义JSP页面的字符编码和对应的MIME类型 --%>
<%@ page errorPage="errorpage.jsp" %> <%-- 定义捕捉例外的对应脚本,当有例外时,自动跳转到此页面 --%>
<%@ page import="java.sql.*" %> <%-- 装载Java的特定类库 --%>
<%@ page import="java.util.*" %>
<%@ page import="enroll.welfareejb.*" %>
<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.rmi.PortableRemoteObject" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.sql.*" %>
<html>
<head>
<title>员工福利信息登记及查询实例</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="5" height="2">
<div align="center"><font face="Courier New, Courier, mono"><b><font size="5" color="#9966CC">员工福利信息登记及查询</font></b></font></div>
</td>
</tr>
<tr>
<td width="34%"> </td>
<td colspan="4"> </td>
</tr>
<tr>
<td colspan="5">
<hr>
</td>
</tr>
<tr>
<td rowspan="3" width="34%"><b><font color="#0000FF">插入新的员工信息 ==></font></b></td>
<%
try
{
Context initial = new InitialContext();
Object objref = initial.lookup("ejb/EmployeeEntityBean");
EmployeeHome sHome = (EmployeeHome)PortableRemoteObject.narrow(objref,EmployeeHome.class);
// 插入一条新的员工记录
sHome.create("x12345", "Marry");
sHome.create("x12346", "Tom");
sHome.create("x12347", "Roy");
%>
<td width="12%"><font color="#009900">工 号:</font></td>
<td width="16%"><font color="#009900">x12345</font></td>
<td width="13%"><font color="#009900">姓 名:</font></td>
<td width="25%"><font color="#009900">Marry</font></td>
</tr>
<tr>
<td width="12%"><font color="#009900">工 号:</font></td>
<td width="16%"><font color="#009900">x12356</font></td>
<td width="13%"><font color="#009900">姓 名:</font></td>
<td width="25%"><font color="#009900">Tom</font></td>
</tr>
<tr>
<td width="12%"><font color="#009900">工 号:</font></td>
<td width="16%"><font color="#009900">x12357</font></td>
<td width="13%"><font color="#009900">姓 名:</font></td>
<td width="25%"><font color="#009900">Roy</font></td>
</tr>
<tr>
<td colspan="5">
<hr>
</td>
</tr>
<tr>
<td width="34%" rowspan="3" bgcolor="#EEEEEE"><b><font color="#0000FF">插入新的福利信息
==></font></b></td>
<%
// 插入一条新的福利资料
objref = initial.lookup("ejb/WelfareEntityBean");
WelfareHome cHome = (WelfareHome)PortableRemoteObject.narrow(objref,WelfareHome.class);
cHome.create("Z0001", "GongJi Jing");
cHome.create("Z0002", "YangLao BaoXian");
cHome.create("Z0003", "YiLiao BaoXian");
%>
<td width="12%" height="13" bgcolor="#EEEEEE"><font color="#009900">编 号:</font></td>
<td width="16%" height="13" bgcolor="#EEEEEE"><font color="#009900">z00001</font></td>
<td width="13%" height="13" bgcolor="#EEEEEE"><font color="#009900">名 称:</font></td>
<td width="25%" height="13" bgcolor="#EEEEEE"><font color="#009900">GongJi
Jing</font></td>
</tr>
<tr>
<td width="12%" bgcolor="#eeeeee"><font color="#009900">编 号:</font></td>
<td width="16%" bgcolor="#eeeeee"><font color="#009900">z00002</font></td>
<td width="13%" bgcolor="#eeeeee"><font color="#009900">名 称:</font></td>
<td width="25%" bgcolor="#eeeeee"><font color="#009900">YangLao BaoXian</font></td>
</tr>
<tr>
<td width="12%" height="2" bgcolor="#eeeeee"><font color="#009900">编 号:</font></td>
<td width="16%" height="2" bgcolor="#eeeeee"><font color="#009900">z00003</font></td>
<td width="13%" height="2" bgcolor="#eeeeee"><font color="#009900">名 称:</font></td>
<td width="25%" height="2" bgcolor="#eeeeee"><font color="#009900">YiLiao
BaoXian</font></td>
</tr>
<tr>
<td colspan="5">
<hr>
</td>
</tr>
<tr>
<td width="34%"><b><font color="#0000FF">Roy登记的福利信息 ==></font></b></td>
<%
// 注册Roy的福利登记资料
objref = initial.lookup("ejb/EnrollSessionBean");
EnrollSessionHome eHome = (EnrollSessionHome)PortableRemoteObject.narrow(objref, EnrollSessionHome.class);
ArrayList welfareItems = new ArrayList();
welfareItems.add("Z0001");
welfareItems.add("Z0003");
EnrollSession enrollsession = eHome.create("x12347");
enrollsession.enroll(welfareItems);
%>
<td colspan="4">
<div align="left"><font color="#009900">z0000 和 z02203</font></div>
</td>
</tr>
<tr>
<td colspan="5">
<hr>
</td>
</tr>
<tr>
<td width="34%" bgcolor="#eeeeee"> </td>
<td colspan="2" bgcolor="#eeeeee">
<div align="center"><font color="#009900">z00003</font></div>
</td>
<td colspan="2" bgcolor="#eeeeee"><font color="#009900">YiLiao BaoXiang</font></td>
</tr>
<tr>
<td width="34%" height="2" bgcolor="#eeeeee"><b><font color="#0000FF">查询Roy的福利信息
==></font></b></td>
<%
// 查询Tom的选课资料
objref = initial.lookup("ejb/EnrollEntityBean");
EnrollHome enrollhome = (EnrollHome)PortableRemoteObject.narrow(objref, EnrollHome.class);
Enroll enroll = enrollhome.findByPrimaryKey("x12347");
ArrayList welfares = enroll.getWelfareItems();
Iterator i = welfares.iterator();
while(i.hasNext())
{
String welfare_id = (String)i.next();
Welfare welfare = cHome.findByPrimaryKey(welfare_id);
%>
<tr>
<td width="34%" height="2" bgcolor="#eeeeee"> </td>
<td height="6" colspan="2" bgcolor="#eeeeee">
<div align="center"><font color="#009900"><%=welfare_id%></font></div>
</td>
<td height="6" colspan="2" bgcolor="#eeeeee"><font color="#009900"><%=welfare.getName()%></font></td>
</tr>
<%
}
}
catch (Exception e)
{
out.println(e.toString());
e.printStackTrace();
}
%>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -