javamail问题 553问题

miaosuan 2003-10-21 09:40:51
请问下列异常是怎么会事,我的程序前几天还好用,这几天却连最简单的邮件也发不了了
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
class javax.mail.SendFailedException: 553-This target address is not our MX service
553-client, nor Your envelope sender is user
at is( allowed to openly use us to relay
553-to any arbitary address throw us.
553 We don't accept this recipient.
...全文
50 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
miaosuan 2003-10-23
  • 打赏
  • 举报
回复
我觉得应该是环境的搭建的问题,或者我不小心改了它的运行环境了
miaosuan 2003-10-21
  • 打赏
  • 举报
回复
<%--senden.jsp--%>
当为
<%--sended.jsp--%>
miaosuan 2003-10-21
  • 打赏
  • 举报
回复
简单例程
<!--form.html-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>邮件例程 - JavaMail - 发送邮件</title>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0">
<form method="post" action="sended.jsp">
<tr>
<td>发信人:</td>
<td><input type="text" name="from" size="80" value="xinhao@perfectsoft.com.cn"></td>
</tr>
<tr>
<td>收信人:</td>
<td><input type="text" name="to" size="80" value="malei1000@sina.com.cn"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="发送"></td>
</tr>
</form>
</table>
</body>
</html>


<%--senden.jsp--%>

<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
<%
String from=request.getParameter("from");
String to=request.getParameter("to");
String mailServer="mail.perfectsoft.com.cn";
//Make a session
Properties properties=System.getProperties();
Session mailsession=Session.getInstance(properties,null);
//Make a message
MimeMessage message=new MimeMessage(mailsession);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
message.setSubject(new java.lang.String("G".getBytes("ISO-8859-1")));

message.setText(new java.lang.String("C".getBytes("ISO-8859-1")));
//connect to transport
Transport transport=mailsession.getTransport("smtp");
transport.connect(mailServer,"xinhao@perfectsoft.com.cn","111111");
//Send the message
try{
transport.sendMessage(message,message.getAllRecipients());
}
catch(MessagingException e){
System.out.println("mail:"+e.toString());
}
transport.close();
%>
jspxnet 2003-10-21
  • 打赏
  • 举报
回复
code 上来别人才好帮你
linsr 2003-10-21
  • 打赏
  • 举报
回复
暂时没有遇到这种情况!
linsr 2003-10-21
  • 打赏
  • 举报
回复
不合法的地址
不可能啊!
只要有一个发送邮件的主机 例如smtp.tom.com
就可以发送到sina.com中
是不是地址输错了。
中文名: 经典Java EE企业应用实战--基于WebLogic/JBoss的JSF+EJB 3+JPA整合开发 原名: 经典Java EE企业应用实战--基于WebLogic/JBoss的JSF+EJB 3+JPA整合开发 作者: 李刚 资源格式: PDF 版本: 第一版 出版社: 电子工业出版社书号: 9787121115349发行时间: 2010年8日 地区: 大陆 语言: 简体中文 简介: 内容简介:   本书是《轻量级java ee企业应用实战》的姊妹篇,《轻量级java ee企业应用实战》主要介绍以spring+hibernate为基础的java ee应用;本书则主要介绍以ejb 3+jpa为基础的java ee应用。ejb 3、jpa规范都属于sun公司所制订的java ee规范,因此把基于ejb 3+jpa的应用称为经典java ee架构,目前这种架构在java开发领域也有极大的市场占有率。   本书介绍了java ee规范的三大主要规范jsf、ejb 3和jpa,其中jsf是sun公司提供的jsf ri;ejb 3部分则包含session bean、message driven bean的详细介绍。所使用的应用服务器是jboss 5.1和weblogic 11g,详细介绍了这两种应用服务器的安装和使用,以及如何在两大主流服务器上安装、部署java ee应用。   本书内容主要包括三部分,第一部分介绍java ee开发的基础知识,以及如何搭建开发环境,包括安装jboss、weblogic应用服务器,以及如何使用svn、netbeans等。第二部分详细讲解了jsf ri、jta、jndi、rmi、jms、javamail、ejb 3的session bean、message driven bean、jpa、jax-ws 2、jaas等java ee知识,这部分知识以jsf+ejb 3+jpa整合开发为重点,通过使用netbeans ide工具上手,带领读者逐步深入jsf+ejb 3+jpa整合开发。这部分内容是笔者讲授“疯狂java实训”的培训讲义,也是本书的重点部分。第三部分提供了一个jsf+ejb 3+ jpa整合开发的项目:电子拍卖系统。这个项目包括5个实体,这5个实体之间具有复杂的关联关系,而且业务逻辑也相对复杂,希望让读者理论联系实际,真正将jsf+ejb 3+jpa整合真正运用到实际开发中。该案例采用目前最流行、最规范的java ee架构,整个应用分为jpa实体层、eao层、业务逻辑层、mvc层和视图层,各层之间分层清晰,层与层之间以松耦合的方法组织在一起。该案例既提供了ide无关的、基于ant管理的项目源码,也提供了基于netbeans ide的项目源码,最大限度地满足读者的需求。 作者简介: 李刚,从事10年的Java EE应用开发。曾任LITEON公司的J2EE技术主管,负责该公司的企业信息平台的架构设计。曾任广州电信、广东龙泉科技等公司的技术培训导师。2007年3月26日的《电脑报》专访人物。现任新东方广州中心软件教学总监,并曾任广东技术师范学院计算机科学系的兼职副教授。   培训的学生已在华为、立信、普信、网易、电信盈科、中企动力等公司就职。   国内知名的高端IT技术作家,已出版《Spring 2.0宝典》、《基于J2EE的Ajax宝典》、《轻量级J2EE企业应用实战》、《Struts 2权威指南》、《Ruby On Rails敏捷开发最佳实践》等著作。 目录: 第0章 学习Java的正确方法 1 0.1 我适合不适合编程 2 0.2 走出象牙塔 4 0.3 学习Java,应该如此疯狂 7 第1章 经典Java EE应用和开发环境 9 1.1 经典Java EE应用概述 10 1.1.1 Java EE 6相关规范 10 1.1.2 经典Java EE应用的分层模型 11 1.1.3 经典Java EE应用的组件 13 1.1.4 经典Java EE应用架构的优势 13 1.1.5 常用的企业服务器 14 1.2 经典Java EE应用相关技术 14 1.2.1 JSP、Servlet和JavaBean及 替代技术 14 1.2.2 JSF及替代技术 15 1.2.3 EJB组件技术简介 15 1.3 JBoss的下载和安装 15 1.3.1 下载和安装JBoss服务器 16 1.3.2 配置JBoss的服务端口 18 1.3.3 进入控制台 19 1.3.4 部署Web应用 22 1.4 WebLogic的下载和安装 24 1.4.1 WebLogic的下载和安装 24 1.4.2 WebLogic的基本配置 25 1.4.3 修改WebLogic的服务端口 29 1.4.4 部署Web应用 30 1.5 NetBeans的安装和使用 32 1.5.1 NetBeans的下载和安装 32 1.5.2 使用NetBeans开发Java EE应用 33 1.5.3 打开NetBeans项目 36 1.5.4 导入Eclipse项目 37 1.6 使用SVN进行协作开发 38 1.6.1 下载和安装SVN服务器 39 1.6.2 配置SVN资源库 39 1.6.3 下载和安装SVN客户端 41 1.6.4 发布项目到服务器 41 1.6.5 从服务器下载项目 42 1.6.6 提交(Commit)修改 42 1.6.7 同步(Update)本地文件 43 1.6.8 添加文件和目录 44 1.6.9 删除文件和目录 45 1.6.10 查看文件或目录的版本变革 45 1.6.11 从以前版本重新开始 46 1.6.12 创建分支 46 1.6.13 沿着分支开发 46 1.6.14 合并分支 47 1.6.15 使用NetBeans作为SVN客户端 48 1.7 本章小结 50 第2章 JSF的基本用法 51 2.1 MVC和JSF 52 2.1.1 MVC和常见MVC框架 52 2.1.2 JSF的优势 56 2.2 下载和安装JSF 57 2.3 JSF使用入门 60 2.3.1 从输入页面开始 60 2.3.2 开发托管Bean 61 2.3.3 定义导航规则 63 2.4 解读JSF配置 65 2.4.1 配置核心控制器(FacesServlet) 65 2.4.2 JSF配置文件结构 68 2.5 托管Bean和表达式语言 69 2.5.1 托管Bean的属性和表达式语言 69 2.5.2 托管Bean的方法 78 2.5.3 托管Bean的分类 80 2.5.4 初始化托管Bean的属性 85 2.5.5 通过FacesContext访问应用环境 89 2.6 导航模型 91 2.6.1 静态导航 93 2.6.2 动态导航 93 2.7 使用UI标签创建视图页面 94 2.7.1 UI标签概述 94 2.7.2 UI标签的通用属性 97 2.7.3 表单相关标签 98 2.7.4 其他标签 103 2.8 JSF的运行流程和生命周期 109 2.8.1 恢复视图阶段 110 2.8.2 应用请求值阶段 110 2.8.3 处理输入校验阶段 111 2.8.4 更新模型的值阶段 111 2.8.5 调用应用阶段 111 2.8.6 生成响应阶段 111 2.9 利用JSF的消息 112 2.10 本章小结 116 第3章 深入使用JSF 117 3.1 JSF事件机制 118 3.1.1 Java事件模型概述 118 3.1.2 Java事件模型示例 119 3.1.3 JSF事件模型 120 3.1.4 Action事件 122 3.1.5 值改变事件 125 3.1.6 生命周期事件 128 3.1.7 将监听器绑定到Bean属性 130 3.2 JSF的国际化支持 132 3.2.1 加载国际化资源文件 132 3.2.2 使用国际化消息 134 3.2.3 动态数据国际化 137 3.2.4 让用户选择语言 142 3.3 使用转换器完成类型转换 143 3.3.1 转换器概述、用途 144 3.3.2 JSF内建转换器 144 3.3.3 使用转换器 145 3.3.4 转换失败后的错误消息 149 3.4 自定义转换器 154 3.4.1 实现转换器类 154 3.4.2 注册转换器 156 3.4.3 使用自定义转换器 159 3.4.4 绑定到Bean属性的转换器 159 3.5 使用验证器进行输入校验 161 3.5.1 输入校验概述 161 3.5.2 JSF内置校验器 162 3.5.3 校验失败后的错误消息 163 3.5.4 必填校验器 165 3.6 自定义校验器 166 3.6.1 开发自定义校验器 166 3.6.2 注册校验器 167 3.6.3 使用自定义校验器 168 3.6.4 为自定义校验器开发专用标签 169 3.6.5 使用托管Bean的方法执行校验 173 3.6.6 绑定到Bean属性的校验器 175 3.7 本章小结 177 第4章 利用JDBC和JTA访问 数据库和管理全局事务 178 4.1 JDBC和容器管理的数据源 179 4.1.1 JDBC概述 179 4.1.2 使用JDBC执行数据库访问 180 4.1.3 使用WebLogic服务器管理的 数据源 182 4.1.4 使用JBoss服务器管理的数据源 187 4.2 事务和JTA 191 4.2.1 事务的基本概念 191 4.2.2 分布式事务处理、XA规范和 2PC协议 192 4.2.3 使用JTA全局事务保证多 数据库的一致性 193 4.3 事务隔离、传播属性的设置 198 4.3.1 并发访问和隔离 198 4.3.2 事务属性 199 4.4 EJB的事务管理 201 4.4.1 容器管理事务(CMT) 201 4.4.2 Bean管理事务(BMT) 201 4.5 事务超时设置 201 4.6 本章小结 203 第5章 JNDI和远程方法调用 204 5.1 JNDI的概念 205 5.1.1 命名服务 205 5.1.2 目录服务 206 5.1.3 JNDI的优点 206 5.2 JNDI编程入门 207 5.2.1 文件系统的命名服务 207 5.2.2 JNDI编程 208 5.3 服务器提供的JNDI支持 212 5.3.1 WebLogic的JNDI支持 212 5.3.2 JBoss的JNDI支持 215 5.4 RMI概述 216 5.4.1 RMI的相关概念 216 5.4.2 RMI的作用和意义 217 5.5 RMI编程 217 5.5.1 开发RMI服务器 217 5.5.2 开发RMI客户端 220 5.5.3 RMI的基本原理 220 5.6 同时作为客户端和服务器的 RMI程序 222 5.6.1 开发客户端程序 222 5.6.2 开发服务器端程序 223 5.7 本章小结 225 第6章 利用JMS实现企业消息处理 226 6.1 面向消息的架构和JMS概述 227 6.1.1 面向消息的应用架构 227 6.1.2 JMS的基础知识和优势 228 6.1.3 JMS的两个重要版本 229 6.2 PTP类型的JMS 230 6.2.1 配置PTP的JMS服务器 231 6.2.2 PTP消息的发送 241 6.2.3 PTP消息的同步接收 244 6.2.4 PTP消息的异步接收 246 6.3 Pub-Sub类型的JMS 248 6.3.1 配置Pub-Sub模型的JMS 服务器 248 6.3.2 消息的生产、消费 250 6.3.3 可靠的JMS订阅 251 6.4 JMS消息 253 6.4.1 JMS消息类型 253 6.4.2 JMS消息头和消息属性 253 6.4.3 重用消息对象 254 6.4.4 JMS传递方式和有效时间 255 6.4.5 设置消息的优先级 256 6.4.6 消息的确认方式 256 6.4.7 消息选择器 257 6.4.8 消息的临时目的261 6.5 使用队列浏览器查看全部消息 264 6.6 JMS和事务 265 6.6.1 使用事务性Session 265 6.6.2 利用JTA全局事务 267 6.7 JMS服务器的异常监听 268 6.8 JMS集群 269 6.9 本章小结 270 第7章 利用JavaMail实现E-mail 271 7.1 E-mail简介 272 7.1.1 SMTP协议简介 272 7.1.2 POP3协议简介 272 7.1.3 IMAP4协议简介 273 7.1.4 E-mail的用途 273 7.2 JavaMail介绍 274 7.2.1 JavaMail下载和安装 274 7.2.2 JavaMail的常用API 275 7.2.3 使用JavaMail发送邮件 277 7.2.4 使用JavaMail接收邮件 281 7.3 应用服务器的JavaMail支持 287 7.3.1 在WebLogic中配置JavaMail 288 7.3.2 通过WebLogic的邮件支持来 发送邮件 290 7.3.3 在JBoss中配置JavaMail 292 7.4 本章小结 294 第8章 会话EJB 295 8.1 EJB概述 296 8.1.1 EJB的概念和意义 296 8.1.2 EJB的发展历史 298 8.1.3 EJB的优势和使用场景 299 8.2 EJB的分类 301 8.2.1 Session Bean的概念和作用 302 8.2.2 Message Driven Bean的概念和 作用 303 8.2.3 实体和JPA 303 8.3 开发无状态的Session Bean 304 8.3.1 开发远程调用的无状态 Session Bean 304 8.3.2 开发本地调用的无状态 Session Bean 311 8.4 发布Session Bean 314 8.4.1 打包EJB-JAR 315 8.4.2 Annotation与部署描述文件 315 8.5 开发有状态的Session Bean 318 8.6 Session Bean的生命周期 321 8.6.1 无状态Session Bean的生命周期 321 8.6.2 有状态Session Bean的生命周期 322 8.6.3 定制Session Bean的生命 周期行为 323 8.7 在Session Bean中使用事务 327 8.7.1 容器管理事务 327 8.7.2 Bean管理事务 330 8.8 拦截器 332 8.9 依赖注入 335 8.9.1 EJB注入 336 8.9.2 资源注入 339 8.10 配置EJB引用 340 8.11 使用计时器进行任务调度 342 8.12 本章小结 345 第9章 消息驱动EJB 346 9.1 JMS和EJB 347 9.1.1 为什么使用MDB 347 9.1.2 使用MDB的设计原则 348 9.2 使用消息驱动Bean 349 9.2.1 使用@MessageDriven和@ActivationConfigProperty 350 9.2.2 实现MessageListener 352 9.2.3 MDB的生命周期 353 9.2.4 MDB中的依赖注入 356 9.2.5 事务管理和异常处理 359 9.3 使用NetBeans开发EJB 359 9.3.1 使用NetBeans开发Session Bean 359 9.3.2 使用NetBeans开发MDB 362 9.4 本章小结 363 第10章 Java持久化API(JPA) 364 10.1 实体简介 365 10.1.1 对象/关系数据库映射(ORM) 365 10.1.2 JPA的映射规则 367 10.1.3 JPA规范简介 368 10.2 实体入门 368 10.2.1 开发实体 369 10.2.2 在Java SE环境下使用 Hibernate JPA实现 370 10.2.3 在Java SE环境下使用 TopLink JPA实现 374 10.2.4 在Java SE环境下使用 EntityManager 377 10.2.5 使用orm.xml管理O/R映射 379 10.3 理解实体 382 10.3.1 持久化上下文和持久化单元 382 10.3.2 实体类的要求 382 10.3.3 实体的状态 383 10.3.4 管理实体的方法 384 10.4 实体的基本映射387 10.4.1 映射实体类的属性 387 10.4.2 将实体映射到多个表 394 10.4.3 映射复合类型的属性 396 10.4.4 映射实体类的主键 398 10.5 关联关系映射 402 10.5.1 单向N-1关联 403 10.5.2 单向1-1关联 406 10.5.3 单向1-N关联 409 10.5.4 单向N-N关联 411 10.5.5 双向1-1关联 414 10.5.6 双向1-N关联 417 10.5.7 双向N-N关联 420 10.5.8 使用Map集合记录关联实体 423 10.5.9 对关联实体进行排序 424 10.6 继承关系映射 426 10.6.1 整个类层次对应一张表的 映射策略 427 10.6.2 连接子类的映射策略 430 10.6.3 每个具体类对应一张表的 映射策略 434 10.7 使用抽象实体和非实体父类 436 10.7.1 抽象实体 436 10.7.2 非实体父类 438 10.7.3 重定义子类实体的外键列 440 10.8 实体的生命周期和监听器 444 10.8.1 实体的生命周期与回调事件 444 10.8.2 使用专门的监听器实现回调 448 10.8.3 为全部实体配置默认监听器 450 10.8.4 排除监听器 452 10.9 本章小结 455 第11章 JPA的查询支持 456 11.1 查询API 457 11.1.1 面向对象的JPQL 457 11.1.2 查询API简介 457 11.2 执行查询 459 11.2.1 使用Query创建查询 459 11.2.2 设置查询参数 459 11.2.3 取得查询结果 460 11.3 JPQL语法 461 11.3.1 使用from子句 462 11.3.2 使用select子句 463 11.3.3 查询部分属性 463 11.3.4 查询中使用构造器 464 11.3.5 使用distinct排除相同的记录 465 11.3.6 where子句和条件表达式 466 11.3.7 使用JPQL函数 466 11.3.8 多态查询 467 11.3.9 关联和连接 469 11.3.10 使用order by进行结果排序 473 11.3.11 JPQL查询的聚集函数 473 11.3.12 使用group by进行分组 474 11.3.13 结果集分页 475 11.3.14 使用子查询 475 11.3.15 命名查询 476 11.4 批量更新和批量删除 478 11.4.1 批量更新 479 11.4.2 批量删除 480 11.5 原生SQL查询 481 11.5.1 使用原生SQL查询 481 11.5.2 结果集映射和实体查询 482 11.5.3 使用命名的原生SQL查询 486 11.5.4 调用存储过程 488 11.6 本章小结 490 第12章 Web层和EJB的整合 491 12.1 Java EE应用的架构 492 12.1.1 SSH架构的复习和应用架构的 思考 492 12.1.2 MVC层和业务层整合 494 12.1.3 DAO模式和EAO模式 495 12.1.4 使用Session Facade模式 499 12.2 从Web层访问Session Bean 500 12.2.1 使用依赖注入访问无状态 Session Bean 501 12.2.2 通过EJB引用访问有状态 Session Bean 507 12.2.3 在工具类中调用Session Bean 509 12.3 在Web层使用JPA 511 12.3.1 使用容器管理的EntityManager 512 12.3.2 在容器内使用应用程序管理的 EntityManager 516 12.3.3 通过ThreadLocal在容器外使用 安全的EntityManager 518 12.4 基于JBoss的JSF+EJB 3+JPA 整合 522 12.4.1 开发JPA实体 522 12.4.2 开发EAO对象 524 12.4.3 开发业务逻辑组件 526 12.4.4 定义JSF的托管Bean来 处理请求 527 12.5 基于WebLogic的Struts 2+ EJB 3+JPA整合 531 12.5.1 开发实体并配置持久化单元 531 12.5.2 开发EAO组件和业务逻辑组件 532 12.5.3 配置EJB引用 532 12.5.4 定义Action来处理用户请求 532 12.6 本章小结 536 第13章 EJB和Web Service 537 13.1 Web Service概述 538 13.1.1 Web Service概述 538 13.1.2 Web Service平台概述 539 13.1.3 Web Service的广泛应用 542 13.2 JAX-WS:Java EE 5 Web Service平台 543 13.2.1 Java EE的Web Service支持 543 13.2.2 为什么选择EJB开发 Web Service 544 13.3 使用JAX-WS 2.0开发 Web Service 545 13.3.1 使用@WebService 545 13.3.2 使用@WebMethod 551 13.3.3 使用@SOAPBinding指定 Web Service风格 553 13.3.4 使用@WebParam 555 13.3.5 使用@WebResult 556 13.3.6 使用@OneWay 558 13.4 客户端调用Web Service 558 13.5 本章小结 559 第14章 利用JAAS开发安全的应用 560 14.1 JAAS概述 561 14.1.1 Java EE应用的安全概述 561 14.1.2 安全域、用户、组和角色概念 561 14.1.3 JAAS的基本流程 563 14.2 管理服务器的用户和组 565 14.2.1 管理WebLogic服务器上的 用户和组 565 14.2.2 管理JBoss服务器上的用户和 角色 573 14.2.3 使用RDBMS管理Jboss 服务器上的用户和角色 574 14.3 开发安全的Web应用 576 14.3.1 声明安全性 576 14.3.2 映射安全角色 579 14.3.3 基于JBoss服务器的表单登录 580 14.3.4 基于WebLogic服务器的安全 角色映射 583 14.3.5 基于WebLogic服务器的 表单登录 583 14.3.6 Web应用中编程式安全 584 14.4 开发安全的Java EE应用 585 14.4.1 为EJB声明安全性 585 14.4.2 应用客户端访问被保护的方法 587 14.4.3 使用Web组件调用EJB被 保护的方法 588 14.4.4 EJB中编程式安全 592 14.5 使用SSL建立安全连接 592 14.5.1 SSL基础知识 593 14.5.2 安装和配置SSL支持 593 14.5.3 在配置描述符中指定安全连接 595 14.6 本章小结 597 第15章 电子拍卖系统 598 15.1 系统功能简介和架构设计 599 15.1.1 系统功能简介 599 15.1.2 系统架构设计 599 15.2 持久层设计 600 15.2.1 系统实体 601 15.2.2 系统E-R图和数据表 601 15.2.3 实现JPA 实体 603 15.2.4 管理持久化单元 612 15.3 实现系统EAO层 614 15.3.1 实现EAO基类 615 15.3.2 实现系统EAO组件 618 15.4 实现业务逻辑层 622 15.4.1 定义业务逻辑组件接口 622 15.4.2 依赖注入EAO组件 624 15.4.3 业务逻辑组件中的异常处理 625 15.4.4 处理用户竞价 627 15.4.5 判断拍卖物品状态 631 15.4.6 事务管理 633 15.5 实现系统Web层 633 15.5.1 安装JSF 633 15.5.2 处理用户登录 634 15.5.3 图形验证码 639 15.5.4 登录控制 642 15.5.5 添加物品 643 15.5.6 处理用户竞价 650 15.6 使用SiteMesh页面装饰 656 15.6.1 在Web应用中安装SiteMesh 656 15.6.2 定义页面装饰 657 15.7 本章小结 659
Sun 官方 J2ee 5.0 教程 The Java EE 5Tutorial For Sun Java System Application Server 9.1 Contents Preface ..................................................................................................................................................29 Part I Introduction ........................................................................................................................................39 1 Overview ..............................................................................................................................................41 Java EE ApplicationModel ................................................................................................................. 42 DistributedMultitiered Applications ............................................................................................... 42 Security ......................................................................................................................................... 43 Java EE Components ................................................................................................................... 44 Java EE Clients .............................................................................................................................. 44 Web Components ........................................................................................................................ 46 Business Components ................................................................................................................. 47 Enterprise Information System Tier .......................................................................................... 48 Java EE Containers .............................................................................................................................. 48 Container Services ....................................................................................................................... 49 Container Types ........................................................................................................................... 49 Web Services Support ......................................................................................................................... 51 XML .............................................................................................................................................. 51 SOAP Transport Protocol ........................................................................................................... 52 WSDL Standard Format .............................................................................................................. 52 UDDI and ebXML Standard Formats ....................................................................................... 52 Java EE Application Assembly andDeployment ............................................................................. 52 Packaging Applications ...................................................................................................................... 53 Development Roles ............................................................................................................................. 54 Java EE Product Provider ............................................................................................................ 55 Tool Provider ............................................................................................................................... 55 Application Component Provider ............................................................................................. 55 3 Application Assembler ................................................................................................................ 56 ApplicationDeployer and Administrator ................................................................................. 56 Java EE 5 APIs ..................................................................................................................................... 57 Enterprise JavaBeans Technology .............................................................................................. 57 Java Servlet Technology .............................................................................................................. 58 JavaServer Pages Technology ..................................................................................................... 58 JavaServer Pages Standard Tag Library ..................................................................................... 58 JavaServer Faces ........................................................................................................................... 58 JavaMessage Service API ............................................................................................................ 59 Java Transaction API ................................................................................................................... 59 JavaMail API ................................................................................................................................ 59 JavaBeans Activation Framework .............................................................................................. 59 Java API for XML Processing ..................................................................................................... 60 Java API for XML Web Services (JAX-WS) .............................................................................. 60 Java Architecture for XML Binding (JAXB) ............................................................................. 60 SOAP with Attachments API for Java ........................................................................................ 60 Java API for XML Registries ....................................................................................................... 61 J2EE Connector Architecture ..................................................................................................... 61 JavaDatabase Connectivity API ................................................................................................. 61 Java Persistence API ..................................................................................................................... 62 JavaNaming and Directory Interface ........................................................................................ 62 Java Authentication and Authorization Service ....................................................................... 62 Simplified Systems Integration ................................................................................................... 63 Sun Java System Application Server Platform Edition 9 ................................................................. 63 Tools ............................................................................................................................................. 63 2 Using theTutorial Examples ..............................................................................................................65 Required Software ............................................................................................................................... 65 Tutorial Bundle ............................................................................................................................ 65 Java Platform, Standard Edition ................................................................................................. 66 Sun Java System Application Server 9.1 ..................................................................................... 66 NetBeans IDE ............................................................................................................................... 67 Apache Ant .................................................................................................................................. 68 Starting and Stopping the Application Server .................................................................................. 68 Starting the Admin Console ............................................................................................................... 69 Contents 4 The Java EE 5Tutorial • September 2007 Starting and Stopping the JavaDBDatabase Server ........................................................................ 69 Building the Examples ........................................................................................................................ 70 Building the Examples UsingNetBeans IDE ............................................................................ 70 Building the Examples on the Command-Line Using Ant ..................................................... 70 Tutorial Example Directory Structure .............................................................................................. 71 Debugging Java EE Applications ....................................................................................................... 72 Using the Server Log .................................................................................................................... 72 Using aDebugger ......................................................................................................................... 73 Part II TheWebTier ........................................................................................................................................ 75 3 Getting Started withWeb Applications ........................................................................................... 77 Web Applications ............................................................................................................................... 77 Web Application Life Cycle ................................................................................................................ 80 WebModules ...................................................................................................................................... 81 Packaging WebModules ............................................................................................................. 83 Deploying aWARFile ................................................................................................................. 84 TestingDeployed WebModules ................................................................................................ 85 ListingDeployed WebModules ................................................................................................. 86 Updating WebModules .............................................................................................................. 86 Undeploying WebModules ........................................................................................................ 88 Configuring Web Applications .......................................................................................................... 89 Mapping URLs to Web Components ........................................................................................ 89 Declaring Welcome Files ............................................................................................................ 91 Setting Initialization Parameters ................................................................................................ 92 Mapping Errors to Error Screens ............................................................................................... 93 Declaring Resource References .................................................................................................. 94 Duke’s Bookstore Examples ............................................................................................................... 96 AccessingDatabases from Web Applications .................................................................................. 97 Populating the ExampleDatabase ............................................................................................. 97 Creating aData Source in the Application Server .................................................................... 98 Further Information about Web Applications ................................................................................. 98 Contents 5 4 Java ServletTechnology .....................................................................................................................99 What Is a Servlet? ................................................................................................................................ 99 The Example Servlets ........................................................................................................................ 100 Troubleshooting Duke's BookstoreDatabase Problems ....................................................... 102 Servlet Life Cycle ............................................................................................................................... 102 Handling Servlet Life-Cycle Events ......................................................................................... 103 Handling Servlet Errors ............................................................................................................. 105 Sharing Information ......................................................................................................................... 105 Using Scope Objects .................................................................................................................. 105 Controlling Concurrent Access to Shared Resources ........................................................... 106 AccessingDatabases .................................................................................................................. 107 Initializing a Servlet ........................................................................................................................... 109 Writing ServiceMethods .................................................................................................................. 110 Getting Information from Requests ........................................................................................ 110 Constructing Responses ............................................................................................................ 112 Filtering Requests and Responses .................................................................................................... 114 Programming Filters .................................................................................................................. 115 Programming Customized Requests and Responses ............................................................ 117 Specifying FilterMappings ....................................................................................................... 119 Invoking Other Web Resources ....................................................................................................... 122 Including Other Resources in the Response ........................................................................... 122 Transferring Control to Another Web Component .............................................................. 124 Accessing the Web Context .............................................................................................................. 124 Maintaining Client State ................................................................................................................... 125 Accessing a Session .................................................................................................................... 125 Associating Objects with a Session .......................................................................................... 126 SessionManagement ................................................................................................................. 126 Session Tracking ........................................................................................................................ 127 Finalizing a Servlet ............................................................................................................................. 128 Tracking Service Requests ........................................................................................................ 129 NotifyingMethods to ShutDown ............................................................................................ 129 Creating Polite Long-RunningMethods ................................................................................. 130 Further Information about Java Servlet Technology .................................................................... 131 Contents 6 The Java EE 5Tutorial • September 2007 5 JavaServer PagesTechnology .........................................................................................................133 What Is a JSP Page? ............................................................................................................................ 133 A Simple JSP Page Example ...................................................................................................... 134 The Example JSP Pages ..................................................................................................................... 136 The Life Cycle of a JSP Page .............................................................................................................. 142 Translation and Compilation ................................................................................................... 142 Execution ................................................................................................................................... 143 Creating Static Content .................................................................................................................... 144 Response and Page Encoding ................................................................................................... 145 CreatingDynamic Content .............................................................................................................. 145 Using Objects within JSP Pages ................................................................................................ 145 Unified Expression Language .......................................................................................................... 146 Immediate andDeferred Evaluation Syntax ........................................................................... 148 Value andMethod Expressions ................................................................................................ 150 Defining a Tag Attribute Type .................................................................................................. 156 Deactivating Expression Evaluation ........................................................................................ 157 Literal Expressions ..................................................................................................................... 158 Resolving Expressions ............................................................................................................... 160 Implicit Objects .......................................................................................................................... 162 Operators ................................................................................................................................... 163 Reserved Words ......................................................................................................................... 163 Examples of EL Expressions ..................................................................................................... 164 Functions ................................................................................................................................... 165 JavaBeans Components .................................................................................................................... 167 JavaBeans ComponentDesign Conventions .......................................................................... 167 Creating and Using a JavaBeans Component ......................................................................... 168 Setting JavaBeans Component Properties .............................................................................. 169 Retrieving JavaBeans Component Properties ........................................................................ 171 Using Custom Tags ........................................................................................................................... 172 Declaring Tag Libraries ............................................................................................................. 172 Including the Tag Library Implementation ............................................................................ 174 Reusing Content in JSP Pages .......................................................................................................... 175 Transferring Control to Another Web Component ..................................................................... 176 jsp:param Element .................................................................................................................... 176 Including an Applet ........................................................................................................................... 176 Setting Properties for Groups of JSP Pages ..................................................................................... 179 Contents 7 Deactivating EL Expression Evaluation .................................................................................. 180 Further Information about JavaServer Pages Technology ........................................................... 183 6 JavaServer Pages Documents .........................................................................................................185 The Example JSPDocument ............................................................................................................ 185 Creating a JSPDocument ................................................................................................................. 188 Declaring Tag Libraries ............................................................................................................. 190 Including Directives in a JSPDocument ................................................................................. 191 Creating Static andDynamic Content .................................................................................... 193 Using the jsp:root Element .................................................................................................... 196 Using the jsp:output Element ................................................................................................ 196 Identifying the JSPDocument to the Container ............................................................................ 200 7 JavaServer Pages StandardTag Library ........................................................................................201 The Example JSP Pages ..................................................................................................................... 201 Using JSTL ......................................................................................................................................... 203 Tag Collaboration ...................................................................................................................... 204 Core Tag Library ............................................................................................................................... 205 Variable Support Tags ............................................................................................................... 205 Flow Control Tags ...................................................................................................................... 206 URL Tags .................................................................................................................................... 210 Miscellaneous Tags .................................................................................................................... 211 XML Tag Library ............................................................................................................................... 211 Core Tags ................................................................................................................................... 213 Flow Control Tags ...................................................................................................................... 214 Transformation Tags ................................................................................................................. 215 Internationalization Tag Library ..................................................................................................... 215 Setting the Locale ....................................................................................................................... 216 Messaging Tags .......................................................................................................................... 216 Formatting Tags ......................................................................................................................... 217 SQL Tag Library ................................................................................................................................ 218 query Tag Result Interface ........................................................................................................ 220 JSTL Functions ................................................................................................................................. 222 Further Information about JSTL ..................................................................................................... 223 Contents 8 The Java EE 5Tutorial • September 2007 8 CustomTags in JSP Pages .................................................................................................................225 What Is a Custom Tag? ..................................................................................................................... 226 The Example JSP Pages ..................................................................................................................... 226 Types of Tags ..................................................................................................................................... 229 Tags with Attributes ................................................................................................................... 229 Tags with Bodies ........................................................................................................................ 232 Tags ThatDefine Variables ....................................................................................................... 232 Communication between Tags ................................................................................................ 233 Encapsulating Reusable Content Using Tag Files ......................................................................... 233 Tag File Location ........................................................................................................................ 235 Tag File Directives ...................................................................................................................... 235 Evaluating Fragments Passed to Tag Files ............................................................................... 242 Custom Tag Examples ............................................................................................................... 243 Tag LibraryDescriptors .................................................................................................................... 247 Top-Level Tag LibraryDescriptor Elements .......................................................................... 248 Declaring Tag Files .................................................................................................................... 249 Declaring TagHandlers ............................................................................................................ 251 Declaring Tag Attributes for TagHandlers ............................................................................ 252 Declaring Tag Variables for TagHandlers .............................................................................. 254 Programming Simple TagHandlers ............................................................................................... 256 Including TagHandlers in Web Applications ........................................................................ 256 How Is a Simple TagHandler Invoked? .................................................................................. 256 TagHandlers for Basic Tags ..................................................................................................... 257 TagHandlers for Tags with Attributes .................................................................................... 257 TagHandlers for Tags with Bodies .......................................................................................... 260 TagHandlers for Tags ThatDefine Variables ........................................................................ 261 Cooperating Tags ....................................................................................................................... 263 TagHandler Examples .............................................................................................................. 265 9 Scripting in JSP Pages .......................................................................................................................273 The Example JSP Pages ..................................................................................................................... 273 Using Scripting ................................................................................................................................. 275 Disabling Scripting ............................................................................................................................ 275 JSPDeclarations ............................................................................................................................... 276 Initializing and Finalizing a JSP Page ....................................................................................... 276 Contents 9 JSP Scriptlets ..................................................................................................................................... 277 JSP Expressions ................................................................................................................................. 277 Programming Tags That Accept Scripting Elements .................................................................... 278 TLD Elements ............................................................................................................................. 278 TagHandlers .............................................................................................................................. 278 Tags with Bodies ........................................................................................................................ 280 Cooperating Tags ....................................................................................................................... 282 Tags ThatDefine Variables ....................................................................................................... 284 10 JavaServer FacesTechnology ..........................................................................................................285 JavaServer Faces Technology User Interface .................................................................................. 285 JavaServer Faces Technology Benefits ............................................................................................ 286 What Is a JavaServer Faces Application? ......................................................................................... 287 A Simple JavaServer Faces Application ........................................................................................... 287 Steps in theDevelopment Process ........................................................................................... 288 Mapping the FacesServlet Instance ...................................................................................... 289 Creating the Pages ...................................................................................................................... 290 Defining PageNavigation ......................................................................................................... 296 Configuring ErrorMessages ..................................................................................................... 297 Developing the Beans ................................................................................................................ 298 AddingManaged BeanDeclarations ....................................................................................... 298 User Interface ComponentModel .................................................................................................. 299 User Interface Component Classes .......................................................................................... 300 Component RenderingModel ................................................................................................. 301 ConversionModel ..................................................................................................................... 304 Event and ListenerModel ......................................................................................................... 305 ValidationModel ....................................................................................................................... 307 NavigationModel .............................................................................................................................. 307 Backing Beans ................................................................................................................................... 309 Creating a Backing Bean Class ................................................................................................. 309 The Life Cycle of a JavaServer Faces Page ....................................................................................... 313 Restore View Phase .................................................................................................................... 315 Further Information about JavaServer Faces Technology ............................................................ 318 Contents 10 The Java EE 5Tutorial • September 2007 11 Using JavaServer FacesTechnology in JSP Pages ........................................................................ 319 The Example JavaServer Faces Application .................................................................................... 319 Setting Up a Page ............................................................................................................................... 322 Using the Core Tags .......................................................................................................................... 325 Adding UI Components to a Page Using the HTML Component Tags ..................................... 327 UI Component Tag Attributes ................................................................................................. 327 Adding a Form Component ..................................................................................................... 329 Using Text Components ........................................................................................................... 330 Using Command Components for Performing Actions andNavigation ........................... 335 UsingData-Bound Table Components .................................................................................. 337 Adding Graphics and Images with the graphicImage Tag ................................................... 340 Laying Out Components with the UIPanel Component ...................................................... 341 Rendering Components for Selecting One Value .................................................................. 343 Rendering Components for SelectingMultiple Values ......................................................... 345 The UISelectItem, UISelectItems, and UISelectItemGroup Components ................... 346 Displaying ErrorMessages with the message and messages Tags ....................................... 349 Using LocalizedData ........................................................................................................................ 350 Loading a Resource Bundle ...................................................................................................... 351 Referencing Localized StaticData ............................................................................................ 352 Referencing ErrorMessages ..................................................................................................... 352 Using the Standard Converters ........................................................................................................ 354 Converting a Component’s Value ............................................................................................ 355 Using DateTimeConverter ....................................................................................................... 356 Using NumberConverter ........................................................................................................... 357 Registering Listeners on Components ............................................................................................ 359 Registering a Value-Change Listener on a Component ........................................................ 359 Registering an Action Listener on a Component ................................................................... 360 Using the Standard Validators ......................................................................................................... 361 Validating a Component’s Value ............................................................................................. 362 Using the LongRangeValidator .............................................................................................. 363 Binding Component Values and Instances to ExternalData Sources ........................................ 364 Binding a Component Value to a Property ............................................................................. 365 Binding a Component Value to an Implicit Object ............................................................... 366 Binding a Component Instance to a Bean Property .............................................................. 368 Binding Converters, Listeners, and Validators to Backing Bean Properties .............................. 369 Referencing a Backing BeanMethod .............................................................................................. 370 Contents 11 Referencing aMethod That PerformsNavigation ................................................................. 371 Referencing aMethod ThatHandles an Action Event .......................................................... 371 Referencing aMethod That Performs Validation .................................................................. 372 Referencing aMethod ThatHandles a Value-change Event ................................................ 372 Using Custom Objects ...................................................................................................................... 373 Using a Custom Converter ....................................................................................................... 374 Using a Custom Validator ......................................................................................................... 375 Using a Custom Component .................................................................................................... 376 12 Developing with JavaServer FacesTechnology ...........................................................................379 Writing Bean Properties ................................................................................................................... 379 Writing Properties Bound to Component Values ................................................................. 380 Writing Properties Bound to Component Instances ............................................................. 388 Writing Properties Bound to Converters, Listeners, or Validators ..................................... 389 Performing Localization ................................................................................................................... 390 Creating a Resource Bundle ...................................................................................................... 390 LocalizingDynamicData .......................................................................................................... 390 LocalizingMessages ................................................................................................................... 391 Creating a Custom Converter .......................................................................................................... 393 Implementing an Event Listener ..................................................................................................... 395 Implementing Value-Change Listeners .................................................................................. 396 Implementing Action Listeners ............................................................................................... 397 Creating a Custom Validator ........................................................................................................... 398 Implementing the Validator Interface ..................................................................................... 399 Creating a Custom Tag .............................................................................................................. 402 Writing Backing BeanMethods ...................................................................................................... 404 Writing aMethod toHandleNavigation ................................................................................ 404 Writing aMethod toHandle an Action Event ........................................................................ 406 Writing aMethod to Perform Validation ............................................................................... 406 Writing aMethod toHandle a Value-Change Event ............................................................. 407 13 Creating CustomUI Components ...................................................................................................409 Determining Whether YouNeed a Custom Component or Renderer ....................................... 410 When to Use a Custom Component ........................................................................................ 410 When to Use a Custom Renderer ............................................................................................. 411 Contents 12 The Java EE 5Tutorial • September 2007 Component, Renderer, and Tag Combinations ..................................................................... 412 Understanding the ImageMap Example ........................................................................................ 413 Why Use JavaServer Faces Technology to Implement an ImageMap? ............................... 413 Understanding the Rendered HTML ...................................................................................... 413 Understanding the JSP Page ..................................................................................................... 414 ConfiguringModelData ........................................................................................................... 416 Summary of the Application Classes ....................................................................................... 417 Steps for Creating a Custom Component ....................................................................................... 418 Creating Custom Component Classes ............................................................................................ 419 Specifying the Component Family .......................................................................................... 421 Performing Encoding ................................................................................................................ 422 PerformingDecoding ................................................................................................................ 424 Enabling Component Properties to Accept Expressions ...................................................... 424 Saving and Restoring State ........................................................................................................ 426 Delegating Rendering to a Renderer ............................................................................................... 427 Creating the Renderer Class ..................................................................................................... 427 Identifying the Renderer Type ................................................................................................. 429 Handling Events for Custom Components .................................................................................... 429 Creating the Component TagHandler ........................................................................................... 430 Retrieving the Component Type .............................................................................................. 431 Setting Component Property Values ....................................................................................... 431 Providing the Renderer Type ................................................................................................... 433 Releasing Resources ................................................................................................................... 434 Defining the Custom Component Tag in a Tag LibraryDescriptor ........................................... 434 14 Configuring JavaServer Faces Applications ..................................................................................437 Application Configuration Resource File ....................................................................................... 437 Configuring Beans ............................................................................................................................. 439 Using the managed-bean Element ............................................................................................ 439 Initializing Properties Using the managed-property Element ............................................ 441 InitializingMaps and Lists ........................................................................................................ 447 Registering Custom ErrorMessages ............................................................................................... 448 Registering Custom Localized Static Text ...................................................................................... 449 Registering a Custom Validator ....................................................................................................... 450 Registering a Custom Converter ..................................................................................................... 451 Contents 13 ConfiguringNavigation Rules ......................................................................................................... 451 Registering a Custom Renderer with a Render Kit ........................................................................ 455 Registering a Custom Component .................................................................................................. 457 Basic Requirements of a JavaServer Faces Application ................................................................. 458 Configuring an Application with aDeploymentDescriptor ................................................ 459 Including the Required JAR Files ............................................................................................. 466 Including the Classes, Pages, and Other Resources ............................................................... 466 15 Internationalizing and LocalizingWeb Applications ..................................................................467 Java Platform Localization Classes .................................................................................................. 467 Providing LocalizedMessages and Labels ...................................................................................... 468 Establishing the Locale .............................................................................................................. 468 Setting the Resource Bundle ..................................................................................................... 469 Retrieving LocalizedMessages ................................................................................................. 470 Date andNumber Formatting ......................................................................................................... 471 Character Sets and Encodings .......................................................................................................... 472 Character Sets ............................................................................................................................. 472 Character Encoding ................................................................................................................... 473 Further Information about Internationalizing Web Applications .............................................. 475 Part III Web Services .....................................................................................................................................477 16 BuildingWeb Services with JAX-WS ...............................................................................................479 Setting the Port .................................................................................................................................. 480 Creating a Simple Web Service and Client with JAX-WS ............................................................ 480 Requirements of a JAX-WS Endpoint ..................................................................................... 481 Coding the Service Endpoint Implementation Class ............................................................ 482 Building, Packaging, andDeploying the Service .................................................................... 482 Testing the Service without a Client ........................................................................................ 484 A Simple JAX-WS Client ........................................................................................................... 484 Types Supported by JAX-WS ........................................................................................................... 486 Web Services Interoperability and JAX-WS .................................................................................. 487 Further Information about JAX-WS ............................................................................................... 487 Contents 14 The Java EE 5Tutorial • September 2007 17 Binding between XML Schema and Java Classes ......................................................................... 489 JAXB Architecture ............................................................................................................................. 489 ArchitecturalOverview ............................................................................................................. 489 The JAXB Binding Process ........................................................................................................ 490 More about Unmarshalling ...................................................................................................... 492 More aboutMarshalling ............................................................................................................ 492 More about Validation .............................................................................................................. 492 Representing XML Content ............................................................................................................. 492 Java Representation of XML Schema ....................................................................................... 492 Binding XML Schemas ..................................................................................................................... 493 Simple TypeDefinitions ............................................................................................................ 493 DefaultData Type Bindings ..................................................................................................... 493 Customizing Generated Classes and Java Program Elements ..................................................... 495 Schema-to-Java .......................................................................................................................... 495 Java-to-Schema .......................................................................................................................... 496 JAXB Examples ................................................................................................................................. 501 JAXB Compiler Options ........................................................................................................... 503 JAXB Schema Generator Option ............................................................................................. 505 About the Schema-to-Java Bindings ........................................................................................ 505 Schema-Derived JAXB Classes ................................................................................................. 508 Basic JAXB Examples ........................................................................................................................ 511 ModifyMarshal Example .......................................................................................................... 511 Unmarshal Validate Example ................................................................................................... 512 Customizing JAXB Bindings ............................................................................................................ 514 Why Customize? ........................................................................................................................ 515 CustomizationOverview .......................................................................................................... 515 Customize Inline Example ........................................................................................................ 526 Datatype Converter Example ................................................................................................... 531 BindingDeclaration Files .......................................................................................................... 533 External Customize Example ................................................................................................... 536 Java-to-Schema Examples ................................................................................................................ 536 CreateMarshal Example ........................................................................................................... 537 XmlAccessorOrder Example .................................................................................................... 538 XmlAdapter Field Example ...................................................................................................... 540 XmlAttribute Field Example ..................................................................................................... 543 XmlRootElement Example ....................................................................................................... 544 Contents 15 XmlSchemaType Class Example .............................................................................................. 545 XmlType Example ..................................................................................................................... 546 Further Information about JAXB .................................................................................................... 548 18 Streaming API for XML ......................................................................................................................549 Why StAX? ........................................................................................................................................ 549 Streaming versusDOM ............................................................................................................. 549 Pull Parsing versus Push Parsing .............................................................................................. 550 StAX Use Cases .......................................................................................................................... 551 Comparing StAX to Other JAXP APIs .................................................................................... 551 StAX API ........................................................................................................................................... 552 Cursor API ................................................................................................................................. 553 Iterator API ................................................................................................................................ 553 Choosing between Cursor and Iterator APIs .......................................................................... 557 Using StAX ........................................................................................................................................ 559 StAX Factory Classes ................................................................................................................. 559 Resources,Namespaces, and Errors ........................................................................................ 561 Reading XML Streams ............................................................................................................... 561 Writing XML Streams ............................................................................................................... 564 Sun’s Streaming XML Parser Implementation .............................................................................. 566 Reporting CDATA Events ......................................................................................................... 566 Streaming XML Parser Factories Implementation ................................................................ 566 Example Code ................................................................................................................................... 567 Example Code Organization .................................................................................................... 567 Example XMLDocument ......................................................................................................... 568 Cursor Example .......................................................................................................................... 568 Cursor-to-Event Example ......................................................................................................... 571 Event Example ............................................................................................................................ 573 Filter Example ............................................................................................................................ 575 Read-and-Write Example ......................................................................................................... 578 Writer Example .......................................................................................................................... 580 Further Information about StAX ..................................................................................................... 583 19 SOAP with Attachments API for Java ............................................................................................. 585 Overview of SAAJ .............................................................................................................................. 586 Contents 16 The Java EE 5Tutorial • September 2007 SAAJMessages ........................................................................................................................... 586 SAAJ Connections ..................................................................................................................... 589 SAAJ Tutorial .................................................................................................................................... 590 Creating and Sending a SimpleMessage ................................................................................. 591 Adding Content to theHeader ................................................................................................. 598 Adding Content to the SOAPPart Object ................................................................................. 599 Adding aDocument to the SOAP Body .................................................................................. 600 ManipulatingMessage Content Using SAAJ orDOMAPIs ................................................ 601 Adding Attachments .................................................................................................................. 601 Adding Attributes ...................................................................................................................... 603 Using SOAP Faults ..................................................................................................................... 608 Code Examples ................................................................................................................................. 613 Request Example ........................................................................................................................ 613 Header Example ......................................................................................................................... 614 DOMandDOMSource Examples ........................................................................................... 617 Attachments Example ............................................................................................................... 622 SOAP Fault Example ................................................................................................................. 624 Further Information about SAAJ .................................................................................................... 627 Part IV Enterprise Beans ...............................................................................................................................629 20 Enterprise Beans ...............................................................................................................................631 What Is an Enterprise Bean? ............................................................................................................ 631 Benefits of Enterprise Beans ..................................................................................................... 631 When to Use Enterprise Beans ................................................................................................. 632 Types of Enterprise Beans ......................................................................................................... 632 What Is a Session Bean? .................................................................................................................... 633 StateManagementModes ......................................................................................................... 633 When to Use Session Beans ...................................................................................................... 634 What Is aMessage-Driven Bean? .................................................................................................... 634 WhatMakesMessage-Driven Beans Different fr

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧