+

Search Tips   |   Advanced Search

 

Example: Locating resources 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-J2EE Servlet Application Programming Interfaces (APIs). The remote request dispatcher (RRD) component follows the same rules to obtain a ServletContext and a remote resource. By using JavaServer Pages standard tag library (JSTL), your application is further removed from obtaining a ServletContext object or RequestDispatcher that is required in the Framework example because the JSTL custom tag does this implicitly. Study the following example of a sample JavaServer Pages 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 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>



 

Related tasks


Task overview: Assembling applications using remote request dispatcher
Configure Web applications to dispatch remote includes
Configure Web applications to service remote includes

 

Related Reference


Example: Locating resources in two different contexts using the framework programming model

 

Reference topic