Task overview: Assembling applications using remote request dispatcher
Remote request dispatcher (RRD) is a pluggable extension to the web container which allows application frameworks, servlets and JSP (JSP) to include content from outside the currently executing resource's Java Virtual Machine (JVM) as part of the response sent to the client.
We must have WebSphere Application Server Network Deployment installed to use remote request dispatcher function. You should also familiarize yourself the limitations of remote request dispatcher. See article, Remote request dispatcher considerations for details.
- Install enterprise application files with the console.
- Configure the sending of include requests between the application and remote resources.
- Configure web applications to dispatch remote includes.
- Configure web applications to service remote includes.
- Optional: Modify the application to locate resources located in two different contexts using the servlet programming model.
The Servlet Programming Model for including resources remotely does not require you to use any non-Java EE Servlet APIs. The remote request dispatcher (RRD) component follows the same rules to obtain a ServletContext and a remote resource. By using JSP standard tag library (JSTL), the application is further removed from obtaining a ServletContext object or RequestDispatcher required in the framework example in the following step because the JSTL custom tag does this implicitly. Study the following example of a sample JSP application to learn how to locate resources that are in two different contexts, investments and banking.
<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 JSP 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>
- Optional: Modify the application to locate resources located in two different contexts using the framework programming model.
The Framework Programming Model for including resources remotely does not require you to use any non- Java EE Servlet Application Programming Interfaces (APIs). When a request is initiated for a ServletContext name that is not presently running inside of the current web container, the remote request dispatcher (RRD) component returns a ServletContext object that can locate a resource that exists anywhere inside a WebSphere Application Sever WebSphere Application Server Network Deployment environment provided that the resource exists and RRD is enabled for that ServletContext object. Study the following sample framework snippet that demonstrates how to locate resources located in two different contexts, investments and banking.
/* 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); }
Results
After enabling at least one enterprise application to dispatch remote includes and at least one enterprise application to service remote includes, RRD is now enabled.
What to do next
Restart the modified applications if already installed or start newly installed applications to enable RRD on each application.
Subtopics
- Configure web applications to dispatch remote includes
We can configure web modules in an application as remote request dispatcher clients to dispatch include requests to resources across web modules that are in different Java virtual machines in a managed node environment through the standard request dispatcher.
- Configure web applications to service remote includes
We can configure web modules in an application as remote request dispatcher servers that are remotely included by other web applications.
- Configure remote request dispatcher caching
The creation and handling of the remote request dispatcher (RRD) message and the transfer of this data across a network creates substantial overhead. To improve performance, the local machine can receive the cache rules of the remote server and know when to cache the response locally to prevent the RRD call altogether.
- Remote dispatcher property settings
Use this page to configure the sending of include requests between the application and remote resources.
- Remote request dispatcher considerations
This topic presents some considerations of which we need to be aware when using remote request dispatcher.
- Servlet extension interfaces
- Remote request dispatcher
Remote Request Dispatcher (RRD) is a pluggable extension to the web container for application frameworks, servlets, and JSP to include content from outside of the current JVM for the resource, as part of the response sent to the client.
Related tasks
Install enterprise application files with the console