We can communicate between two seperate webapplication through some ways,
1.append the parameters whaerver you need to send with "query string" like http://example.com/actionclass? name=value&name=value
2.use common XML file for get and set the values in common location,use sax parser od dom parser for parsing xml files.
Now I want to send response to A1(client - Browser). How to send this response, please provide some code for understanding.
You can invoke A2(Server) url from A1(Client) web application just like any other browser client. If A1 and A2 are deployed in a same container then that'll save you from proving relative path to the resource (ofcourse, direct url always works). One thing you might be interested in about is "Security".
1. Should A2 web application be authenticated before accessing any of its resources?
2. What authorization priveleges are provided to A1 application to access A2 resources?
If you also need to consider the above, you can refer web.xml and server specific descriptor files (e.g.JBoss - jboss-web.xml, WAS ibm-web-bnd.xmi, ibm-web-ext.xmi files,...) for security realms.
Hope I haven't made too complicated
As per my query, I want to identify the browser to whom I suppose to send response (the page could be in different application). Please provide some code.
Not sure if I understood your question correctly. What do you mean to identify a browser? If you want to display something (jsp or servlet content) on to browser, just invoke that servlet or jsp url. Can you put down detailed scenario what you are trying to achieve?
Please go through the attached image, you will find request-response as per the numbering on the image.
Here B1 and B2 are 2 different browsers.
Here S1 and S2 are 2 different application.
As per the scenario, I want to recognise B1 from S1, how to send response to B1?
Do you have any solution to recognise B1 from S1 in response no. '6'.
It has been asked before and let me ask again - what exactly do you mean by 'recognise'? Or to put it in another way - what do you hope to achieve by being able to recognise B1? What is it that you would do if you could recognise B1 that you are unable to do so otherwise?
Maybe if you tell us that, you will find the answer to the bigger picture than in assuming that the answer to it lies in the ability to recognise the browser.
See, actually I want to send response to client B1 without refreshing page. That means when B1 send request no. 3 to S1, then S1 redirect this requst to S2 and forget about client B1. After some time S1 get data from S2. That time I want to send this data to Client B1, without loosing previous data on that page (B1).
Hope this explaination not cofusing ....
Recognising browser means, identify client (browser) for sending response.
You do not have to. Whatever you write to the output stream of the response object goes back to whoever initiated the request which in this case is the browser
See, actually I want to send response to client B1 without refreshing page.
You will have to use ajax for that
That means when B1 send request no. 3 to S1, then S1 redirect this requst to S2 and forget about client B1. After some time S1 get data from S2. That time I want to send this data to Client B1, without loosing previous data on that page (B1).
You are confused how you would achieve the interaction. Let me try explain that.
1. A Servlet on S1 receives the request.
2. Within the scope of this request
i. The servlet makes a call to S2 (using either HttpURLConnection or HttpClient api)
ii. The servlet receives a response from s1 which is extracted out and transformed if necessary.
3. The servlet now flushes back the transformed response it received from s2 back to the browser.
The pseudo-code below may help you visualize better
As you would see above, you do not have to write code to recognise the browser. Anything written to the output stream of the response is flushed back to the browser.