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 184.108.40.206 (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