从 WebSphere Application Server V 5.x 迁移 Web 应用程序组件
无需迁移先前版本的 WebSphere® Application Server 中部署的 Web 应用程序。 除非在 Servlet 3.1 或 JSP 2.3 规范中更改了行为,否则仍支持 Java™ Servlet 规范的 2.2 和更高版本以及 JavaServer Pages (JSP) 规范的 1.2 和 1.4 版本。 这些更改通常在其相应规范中作了更详细的描述。
有关此任务
在以下情况下,Servlet 迁移可能是一个问题:
- 实现 WebSphere Application Server 内部 servlet 以绕过 WebSphere Application Server V 4.x 单个应用程序路径限制
- 扩展依赖 Servlet 配置 XML 文件中配置信息的 PageListServlet
- 通过使用
encodeRedirectURL函数或在非上下文根中启动来调用 servlet 的response.sendRedirect方法 - 取决于要设置的缺省 Content-Type 响应头或者进行
getWriter调用后setContentType调用的行为。 此行为由 WebSphere Application Server 版本级别使用具有值 V4 V5的 Web 容器定制属性 com.ibm.ws.webcontainer.contenttypecompatibility 进行设置。 V6或 V7。 每个版本的行为如表 1 中所述。表 1. Web 容器定制属性。。 此表在第一列中描述了定制属性信息。 第一列后的每一列都描述了特定版本的版本行为。 描述的版本为 V 4 , V 5 , V 6 和 V 7。 定制属性信息 V4 V5 V6 V7 缺省 Content-Type 文本/html text/html; charset= <default_ encoding> 无 无 如果 Content-Type 上不存在属性,那么将 Charset 追加到 getWriter 示例:response.setCharacterEncoding("UTF-8"); response.setContentType("text/xml"); response.getWriter();
文本/html 文本/html text/xml; charset=UTF-8 text/xml; charset=UTF-8 如果在 getWriter 后使用“;charset=”部分调用了 setContentType 属性,那么从 Content-Type 属性中除去 charset 示例:setContentType("text/html;charset=ISO-8859-7"); getWriter(); setContentType("text/xml;charset=UTF-8");
文本/html 文本/html 文本/html text/xml; charset=ISO-8859-7
如果应用程序引用未命名包中的 JSP 页面实现类,或者如果在 V 5.x中安装 WebSphere Application Server V 4.x EAR 文件 (在 V 4.x 中使用 JSP Precompile 选项部署) ,那么 JSP 迁移可能会引起关注。 从 WebSphere Application Server V 5.x迁移时,需要重新编译所有 JSP 页面。
如果应用程序引用未命名包中的 JSP 页面实现类,或者如果在 V 5.x中安装 WebSphere Application Server V 4.0.1 EAR 文件 (在带有 JSP Precompile 选项的 V 4.0.1 中部署) ,那么可能会引起 JSP 迁移问题。 从 WebSphere Application Server V 5.x迁移时,需要重新编译所有 JSP 页面。
但是, Java EE 5 或更高版本的模块可以存在于包含Java EE 5 之前的文件并使用 .xmi 文件扩展名的应用程序中。
ibm-webservices-ext.xmi、ibm-webservices-bnd.xmi、ibm-webservicesclient-bnd.xmi、ibm-webservicesclient-ext.xmi 和 ibm-portlet-ext.xmi 文件继续使用 .xmi 文件扩展名。
如果迁移问题应用于您的 Web 应用程序,请遵循这些步骤: