Originally posted by Ganapathi Raman:
We want to give the request and response objects from one servlet (say Servlet A) to another (say Servlet B). But we do not want Servlet A to wait until Servlet B finishes this request. We want to Servlet A to dispatch this info to Servlet B and continue with its own processing [...]
There seems to be something fundamentally wrong about what you're trying to do. HTTP Servlets are objects which generate HTTP responses in response to HTTP requests, or delegate the generation of such responses.
If there is some work which should be done after forwarding the request to bean B, this work has no part in generating the response. For that reason alone it does not belong in a servlet, but in an ordinary
Java class. Why not create a Runnable class C which implements this work? Immediately before the forward, you could say
new Thread(new C()).run() to kick off the background work (probably not exactly this, but you get my drift).
If servlet A gets a lot of load, consider using an application-bound thread pool consuming Runnable jobs from a job queue.
- Peter