JavaEE5学习笔记07-Web层与EJB集成总结(2):servlet与EJB集成结果展示
之后在写2个jsp页面
insertUserFormServlet.jsp
<%@ page language="java" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
??? <head>
??? </head>
??? <body>
?????? <form name="form1" method="post" action="servlet/EJBServlet">
?????????? <table width="354" height="120" border="1" cellpadding="1"
????????????? cellspacing="1" bordercolor="#000000">
????????????? <tr>
????????????????? <td width="117">
???????????????????? <div align="center">
???????????????????????? 主键:
???????????????????? </div>
????????????????? </td>
????????????????? <td width="224">
???????????????????? <div align="left">
???????????????????????? <label>
??????????????????????????? <input type="text" name="id">
???????????????????????? </label>
???????????????????? </div>
????????????????? </td>
????????????? </tr>
????????????? <tr>
????????????????? <td>
???????????????????? <div align="center">
???????????????????????? 姓名:
???????????????????? </div>
????????????????? </td>
????????????????? <td>
???????????????????? <div align="left">
????????????????? ?????? <input type="text" name="name">
???????????????????? </div>
????????????????? </td>
????????????? </tr>
????????????? <tr>
????????????????? <td colspan="2">
???????????????????? <div align="center">
???????????????????????? <label>
??????????????????????????? <input type="submit" name="Submit" value="增加数据">
???????????????????????? </label>
???????????????????? </div>
????????????????? </td>
????????????? </tr>
?????????? </table>
?????? </form>
??? </body>
</html>
insertUserFormList.jsp
<%@ page language="java" pageEncoding="utf-8"%>
<%
??? out.print("插入数据成功!");
%>
部署ear(之后会提到如何打包部署),看到效果如下
?提交后,插入成功数据库效果如下
?证明servlet调用EJB组件成功了。