使用 RRD 来部署 Web 应用程序以及远程 Web 或 Portlet 应用程序
远程请求分派器 (RRD) 是 Web 容器的可插入扩展,它使应用程序框架、Servlet 和 JavaServer Pages (JSP) 可以将来自当前执行资源的 Java™ 虚拟机 (JVM) 外部的内容包括在发送到客户机的响应中。
开始之前
过程
- 使用控制台来安装企业应用程序文件。
- 配置应用程序与远程资源之间的包括请求的发送方式。
- 配置 Web 应用程序以分派远程包含。
- 配置 Web 应用程序以处理远程包括。
- 可选: 修改应用程序,以在使用 Servlet 编程模型的两种不同上下文中查找资源。
用于以远程方式包括资源的 Servlet 编程模型不要求您使用任何非 Java Platform, Enterprise Edition (Java EE) Servlet 应用程序编程接口 (API)。远程请求分派器 (RRD) 组件遵循相同的规则来获取 ServletContext 和远程资源。通过使用 JavaServer Pages 标准标记库 (JSTL),会通过获取“框架示例”中必需的 ServletContext 对象或 RequestDispatcher 来进一步除去应用程序,因为 JSTL 定制标记会隐式地完成此操作。请研究样本 JavaServer Pages 应用程序的以下示例,以了解如何查找两种不同上下文(即,投资和银行)中的资源。
<HEAD> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8059-1" isELIgnored="false" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" $> </HEAD> <BODY> <%-- Programming example using JavaServer Pages and JavaSever Pages Standard Tag Library (JSTL). JSTL provides a custom tag to import contents (in servlet and JSP terms include) in the scope of the same request from outside of the current web module context by specifying a context parameter. JSTL restriction: The web module that is imported must run inside of the same JVM as the calling resource if imported URL is not fully qualified. RRD extends this functionality by permitting the web module to be located within the scope of the current WebSphere Application Server core group versus the scope of the JVM. --%> <hr size="5"/> <%-- Include resource investmentSummary.jsp located in the web application with context root of /investments. --%> <c:import url="investmentSummary.jsp" context="/investments"/> <hr size="5"/> <%-- Include resource accountSummary.jsp located in the web application with context root of /banking. --%> <c:import url="accountSummary.jsp" context="/banking"/> <hr size="5"/> </BODY> </HTML>
- 可选: 修改应用程序,以在使用框架编程模型的两种不同上下文中查找资源。
用于以远程方式包括资源的框架编程模型不要求您使用任何非 Java Platform, Enterprise Edition (Java EE) Servlet 应用程序编程接口 (API)。当为在当前 Web 容器内部目前未运行的 ServletContext 名称发起请求时,远程请求分派器 (RRD) 组件会返回可以查找资源的 ServletContext 对象,如果该资源存在并且为该 ServletContext 对象启用了 RRD,那么该资源存在于 WebSphere Application Sever WebSphere Application Server Network Deployment 环境中的任何位置。请研究显示如何查找两种不同上下文(即,投资和银行)中的资源的以下样本框架片段。
/* Programming example using a generic framework. Servlet Specification provides an API to obtain a servlet context in the scope of the same request different from the current web module context by specifying a context parameter. Servlet Specification restriction: The web module that obtain must run inside of the same JVM as the calling resource. RRD extends this functionality by permitting the web module to be located within the scope of the current WebSphere Application Server core group versus the scope of the JVM. */ protected void frameworkCall (ServletContext context, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException( PrintWriter writer = response.getWriter(); writer.write("<HTML>"); writer.write("<HEAD>"); writer.write("</HEAD>"); writer.write("<BODY>"); writer.write("<hr size=\"5/">); //Include resource investmentSummary.jsp located in web application //with context root of /investments. RequestDispatcher rd = getRequestDispatcher ( context, "/investments", "/investmentSummary.jsp"); rd.include(request, response); writer.write("<hr size=\"5/">); //Include resource accountSummary.jsp located in web application //with context root of /banking. rd = getRequestDispatcher ( context, "/banking", "/accountSummary.jsp"); rd.include(request, response); writer.write("</BODY>"); writer.write("</HTML>"); } private RequestDispatcher getRequestDispatcher (ServletContext context, String contextName, String resource) { return context.getContext(contexName).getRequestDispatcher(resource); }
结果
下一步做什么
子主题
远程请求分派器
远程请求分派器 (RRD) 是应用程序框架、Servlet 和 JavaServer Pages 的 Web 容器的可插入扩展,以将资源的当前 Java 虚拟机 (JVM) 外部的内容包括在发送到客户机的响应中。


http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=tweb_rrd_overview
文件名:tweb_rrd_overview.html