createRoster.jsp
资源名称:某公司的java培训教材 [点击查看]
上传用户:dinglihq
上传日期:2013-02-04
资源大小:99958k
文件大小:2k
源码类别:
Java编程
开发平台:
Java
- <%@ page contentType="text/html; charset=GBK" %>
- <%@ page language="java" %>
- <%@ page import="javax.naming.InitialContext" %>
- <%@ page import="cmpsample.*" %>
- <html>
- <head><title>Chapter 11 CMP 2.0 Sample Example </title></head>
- <body bgcolor="white">
- <center>
- <h2>Chapter 11 CMP 2.0 RosterEJB - Create a Roster</h2>
- <p>
- <form method="post" action="/WebApp/createRoster.jsp">
- <table border=10>
- <tr>
- <td>Roster ID: </td>
- <td><input type="text" name="id" size="11" value=""></td>
- </tr>
- <tr>
- <td>Schedule ID: </td>
- <td><input type="text" name="scheduleID" size="25" value=""></td>
- </tr>
- <tr>
- <td>Student ID: </td>
- <td><input type="text" name="studentID" size="25" value=""></td>
- </tr>
- </table>
- <p>
- <input type="submit" name="submit" value="Submit">
- <p>
- </form>
- <%
- String id = request.getParameter("id");
- String scheduleID = request.getParameter("scheduleID");
- String studentID = request.getParameter("studentID");
- if (id != null && !"".equals(id)) {
- try {
- InitialContext ic = new InitialContext();
- Object o = ic.lookup("Roster");
- RosterHome home = (RosterHome) o;
- Roster roster = home.create(id, scheduleID, studentID);
- %>
- New Roster created:<br>
- <%=roster.fetchStudentID()%>,
- <%=roster.fetchScheduleID()%>
- </p>
- <a href = "/WebApp/searchRoster.jsp">SEARCH</a></p>
- <%
- } catch(Exception e) {
- e.printStackTrace();
- out.println("Create new Roster FAILED : " + e.toString());
- }
- }
- %>
- <hr>
- [<a href="/WebApp/index.html">HOME</a>]
- </center>
- </body>
- </html>