createAddress.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 AddressEJB - Create an Address </h2>
- <p>
- <form method="post" action="/WebApp/createAddress.jsp">
- <table border=10>
- <tr>
- <td>Student ID: </td>
- <td><input type="text" name="id" size="11" value=""></td>
- </tr>
- <tr>
- <td>Address ID: </td>
- <td><input type="text" name="addressID" size="11" value=""></td>
- </tr>
- <tr>
- <td>Street Name: </td>
- <td><input type="text" name="streetName" size="25" value=""></td>
- </tr>
- <tr>
- <td>City Name: </td>
- <td><input type="text" name="city" size="15" value=""></td>
- </tr>
- <tr>
- <td>State Name: </td>
- <td><input type="text" name="state" size="2" value=""></td>
- </tr>
- <tr>
- <td>Zip Code: </td>
- <td><input type="text" name="zip" size="5" value=""></td>
- </tr>
- </table>
- <p>
- <input type="submit" name="submit" value="Submit">
- <p>
- </form>
- <%
- String id = request.getParameter("id");
- String AddressID = request.getParameter("addressID");
- String StreetName = request.getParameter("streetName");
- String CityName = request.getParameter("city");
- String StateName = request.getParameter("state");
- String ZipCode = request.getParameter("zip");
- if (id != null && !"".equals(id)) {
- try {
- InitialContext ic = new InitialContext();
- Object o = ic.lookup("Address");
- AddressHome home = (AddressHome) o;
- Address address = home.create(id, AddressID, StreetName, CityName, ZipCode, StateName);
- %>
- New Address created: <br>
- <%=address.getStreet()%>,
- <%=address.getCity()%>
- </p>
- <a href = "/WebApp/searchAddress.jsp">SEARCH</a></p>
- <%
- } catch(Exception e) {
- e.printStackTrace();
- out.println("Create new Address FAILED : " + e.toString());
- }
- }
- %>
- <hr>
- [<a href="/WebApp/index.html">HOME</a>]
- </center>
- </body>
- </html>