This discussion is archived
1 Reply Latest reply: Jun 28, 2011 12:17 AM by gimbal2 RSS

Communicate between two Servlet in different Applications

842310 Newbie
Currently Being Moderated
I have two servlet Servlet1 and Servlet in application App1 and app2 respectively.

I would like the following
Servlet1.doPost(request,response) {
 
     1. Calls Servlet2.doPost(request,response); or Send the request/response to Servlet2
     2. Servlet2 gets values form request
     3. Servlet2 will set some values using request.setAttribute
      
     Object obj = request.getAttribute("name");
   
}
Please let me know how to achieve that.

I think it can be acheived by HttpClient but I read somwwhere it has performance issue. Please highlight me in this regard also.
  • 1. Re: Communicate between two Servlet in different Applications
    gimbal2 Guru
    Currently Being Moderated
    Debopam wrote:
    Please let me know how to achieve that.
    Seems like you do not want to call Servlet2, what you want to do is be able to invoke the logic that Servlet2 invokes from Servlet1. Putting the logic in a class of its own and calling it from both Servlet1 and Servlet2 is always an option. Otherwise you have to do very icky forwarding logic, setting flags so you prevent the servlets from going in an endless forwarding cycle.

    Alternatively, you could create a common abstract base class for both servlets which has a method with the logic that both servlets need.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points