Hi!
I am santosh. I need example code and theory for the following issue. One of my servlet is residing in the tomcat server. One of my page is calling this servlet and I need to pass this request and response to the other servlet which is running in another Webserver. Can any body help in this issuue.please clarify me how they work in different servers context.I am so much thank ful if anybody gives me a solution with example..
regards
santosh
-
Servlet to Servlet communication which are in diff web servers (7 messages)
- Posted by: santosh kumar
- Posted on: October 14 2003 08:18 EDT
Threaded Messages (7)
- Servlet to Servlet communication which are in diff web servers by Viswa Cheenu on October 14 2003 09:11 EDT
- use the class of HttpURLConnection in servlet to request other by jk325 jk325 on October 14 2003 09:48 EDT
- use the class of HttpURLConnection in servlet to request other by santosh kumar on October 14 2003 10:47 EDT
- Servlet to Servlet communication which are in diff web servers by Paul Strack on October 14 2003 09:49 EDT
-
Servlet to Servlet communication which are in diff web servers by santosh kumar on October 14 2003 10:49 EDT
- Servlet to Servlet communication which are in diff web servers by Paul Strack on October 14 2003 03:05 EDT
-
Servlet to Servlet communication which are in diff web servers by santosh kumar on October 14 2003 10:49 EDT
- test comment by Debasish Halder on October 17 2003 05:57 EDT
- use the class of HttpURLConnection in servlet to request other by jk325 jk325 on October 14 2003 09:48 EDT
-
Servlet to Servlet communication which are in diff web servers[ Go to top ]
- Posted by: Viswa Cheenu
- Posted on: October 14 2003 09:11 EDT
- in response to santosh kumar
Servlet Spec says Servlet Context will work between the apps within the server only. -
use the class of HttpURLConnection in servlet to request other[ Go to top ]
- Posted by: jk325 jk325
- Posted on: October 14 2003 09:48 EDT
- in response to Viswa Cheenu
for example:
String url="http://172.16.0.1:7001/TranPro/Tran3800";
URL url = new URL(Url);
HttpURLConnection connection =(HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setDoOutput(true);
OutputStreamWriter ostream = new OutputStreamWriter(connection.getOutputStream());
if(buffer!=""){
BufferedWriter out = new BufferedWriter(ostream);
//out.write(buffer);
out.flush();
out.close();
}
InputStream stream = connection.getInputStream();
BufferedInputStream in = new BufferedInputStream(stream);
time=System.currentTimeMillis();
int i = 0;
while ((i = in.read()) != -1) {
System.out.write(i);
}
in.close();
connection.disconnect(); -
use the class of HttpURLConnection in servlet to request other[ Go to top ]
- Posted by: santosh kumar
- Posted on: October 14 2003 10:47 EDT
- in response to jk325 jk325
Thank you very much,
I will try with this code accords to my application. That means i have to create a url connection object and set the url parameters.thank you very much.I hope that you will help me in the following problem
I have one more problem
We have one security server and application server. In security server the servlet handles the request from the client. It is authenticated and if success occurs it redirects the request to application server. Whenere I need to write a program which should serve the security server request. It has to receive the request and process and send it back to the security server and the security server will return the response to the client depending on his role. The communication between security server and application server should have to use rmi protocol. what programs do i need to develop..if i write socket programming in appserver...or is there any other solution to solve this problem..please reply to me asap. as i need to solve this issue on an emergency base.
if possible please give me one example or resource addresses.
i will be so much thank ful -
Servlet to Servlet communication which are in diff web servers[ Go to top ]
- Posted by: Paul Strack
- Posted on: October 14 2003 09:49 EDT
- in response to Viswa Cheenu
As Viswa said, directly passing the request and response to a servlet in a different server won't work.
The most straightforward form of servlet-engine-to-servlet-engine communication is to have your first servlet invoke the remote servlet as an normal HTTP client, for example using the java.net.URL and java.net.URLConnection classes. -
Servlet to Servlet communication which are in diff web servers[ Go to top ]
- Posted by: santosh kumar
- Posted on: October 14 2003 10:49 EDT
- in response to Paul Strack
Thank you very much for the solution. Can you give me some of the site names or resouce names so i can quickly go through the code.I hope that you will help me inthe following problem...
We have one security server and application server. In security server the servlet handles the request from the client. It is authenticated and if success occurs it redirects the request to application server. Whenere I need to write a program which should serve the security server request. It has to receive the request and process and send it back to the security server and the security server will return the response to the client depending on his role. The communication between security server and application server should have to use rmi protocol. what programs do i need to develop..if i write socket programming in appserver...or is there any other solution to solve this problem..please reply to me asap. as i need to solve this issue on an emergency base.
if possible please give me one example or resource addresses.
i will be so much thank ful
regards
santosh -
Servlet to Servlet communication which are in diff web servers[ Go to top ]
- Posted by: Paul Strack
- Posted on: October 14 2003 15:05 EDT
- in response to santosh kumar
// In your servlet:
URL url = new URL("http://<host-name>/RemoteServlet?request-data");
URLConnection con = url.openConnection();
con.connect();
// To process the response:
InputStream is = (InputStream) con.getContent();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line = br.readLine();
while (line != null) {
System.out.println(line);
line = br.readLine();
}
br.close(); -
test comment[ Go to top ]
- Posted by: Debasish Halder
- Posted on: October 17 2003 05:57 EDT
- in response to Viswa Cheenu
Soory I am putting a junk mesg >pls ignore this