Task overview: Assembling applications using remote request dispatcher


 

+

Search Tips   |   Advanced Search

 

Remote request dispatcher (RRD) is a pluggable extension to the Web container which allows application frameworks, servlets and JSPs to include content from outside the currently executing resource's JVM as part of the response sent to the client.

  1. Install enterprise application files

  2. Configure the sending of include requests between the application and remote resources.

  3. Modify the application to locate resources located in two different contexts using the servlet model.

    The servlet programming model for including remote resources does not require any non-J2EE Servlet APIs. The RRD component follows the same rules to obtain a ServletContext and a remote resource.

    By using the standard tag library (JSTL), apps are removed from obtaining ServletContext objects or RequestDispatcher required in the framework example in the following step. The JSTL custom tag does this implicitly.

    The following sample JSP locates resources 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>
    
    <%--
    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.
    
    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 permits the Web module to 
    be located within the scope of the  current WAS core group versus the scope of the JVM.
    
    --%>
    
    <%--    
        Include resource investmentSummary.jsp located in the 
        Web app with context root of /investments. 
    --%>
    
    <c:import url="investmentSummary.jsp" context="/investments"/>
    
    <%--    
        Include resource accountSummary.jsp located in the 
        Web app  with context root of /banking. 
    --%>
    
    <c:import url="accountSummary.jsp" context="/banking"/>
    
    
    </BODY>
    </HTML>
    

  4. Modify the application to locate resources located in two different contexts using the framework model.

    The Framework Programming Model for including resources remotely does not require you to use any non-J2EE Servlet API. When a request is initiated for a ServletContext name not presently running inside of the current Web container, the RRD component returns a ServletContext object that can locate a resource that exists anywhere inside a WAS ND 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 WAS 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 app       
          
    //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 app       
          
    //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.

 

Next steps

Restart the modified applications if already installed or start newly installed applications to enable RRD on each application.


Remote request dispatcher Configure Web apps to dispatch remote includes
Configure Web apps to service remote includes
Configure remote request dispatcher caching
Remote dispatcher property settings
Remote request dispatcher considerations
Servlet extension interfaces