Integrating ADF and Servlets
By Duncan Mills on Apr 27, 2011
Inspired by a recent (OK not so recent but I’ve been busy) OTN Code Harvest article from Frank Nimphius and prompted by a specific customer question along the same lines I’ve put together a simple example project that demonstrates the technique in a very simple manner. Frank is discussing the common case of reusing ADF Business Components Application Module context, however, my sample is a little simpler and is just using a humble POJO for simplicity.
You can download the sample workspace from here: Sharing ADF context with a Servlet.
This sample is based on JDeveloper / ADF 188.8.131.52 (Fusion Middleware Patchset 3) but should upgrade to newer 11.1.1.n versions without a problem. There are no database dependencies.
To try it out, just unzip the sample, make and run index.jspx in the ViewController project.
This code demonstrates how a Servlet within an application can share the same data control context (frame) as the underlying UI pages and Task Flows within that application.
This approach is useful when you are creating integrated applications where servlets are leveraged to add functionality to the application such as AJAX calls or email generation
- The Servlet path is mapped to the same pageDef as the required ADF content in the DataBinding.cpx file
- The Servlet is registered with the ADF Binding filter in the web.xml file
- The "calling" page (or taskflow) will temporarily store the current Data Control Frame name on the session
- The servlet will retrieve the data control frame name and use that to access the binding that is required in the correct context