• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to forward request to another webapplication in servlets  RSS feed

 
santosh mudholam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have to forward my request to another webApplication using post request parameters.
In this case Webaplication-1 need send request using post request params to Webapplication-2 & once Webaaplication-2 receives request it has to process & display output.
For this have tried below 2 options which Servlet API provides.
1. RequestDispatcher : this will used to forward request to another resource within the application.
2. sendRedirect() : this method support doGet() of Servlet.

3. Using HttpClient, which is provided by Apache able to do but it will not displaying Output,It sending back response to Webapplication-1 .

Is there any option which will handover request from one webapplication to another webapplication.
 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
once Webaaplication-2 receives request it has to process & display output

where do you want to display results - in Web application 1 OR Web application 2 ?
What is the View part of your Web application 1 and 2 ? JSP ? FTL ?
Assuming you want to display result/output in Web application 1, then, you can use HTML Iframe tag to directly display output received from Web application 2 to JSP page of Web application 1.
 
santosh mudholam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Abhay,

In my application I don't have view part, have to receive request in Struts1.1 controller & make a call to Web service which we published to clients.
There is one new requirement where based on some condition we don't want to make call to our web service instead forward the request to Some other Web application which is running in different machine, here Second application has to display result.
Note : have to send post params to second application.


Appreciate your help.

thank you.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which is running in different machine, here Second application has to display result. Note : have to send post params to second application.

This part will not work, as you have found out already.
 
Anindya Roy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to use SOA architecture like Webservice(SOAP or REST), JMS etc. for communication between multiple external applications
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to use SOA architecture like Webservice(SOAP or REST), JMS etc. for communication between multiple external applications

(Just nitpicking: Using a WS does not make the overall architecture a SOA.) One approach might be to send all parameters that are included in the POST to the 2nd server via an HTTP call (possible using a WS API), and have the 2ns server send back a secure token that identifies the set of data you sent. Then you can do do a redirect to the 2nd server with nothing but the token as URL parameter.
 
Anindya Roy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Just nitpicking: Using a WS does not make the overall architecture a SOA.)


I did not say that WS makes overall architecture but it is one of the implementation. SOA is not any technology it's all about a concept nothing else.

Have a look http://www.oracle.com/technetwork/articles/javase/soa-142870.html
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!