Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

calling more than one servlet  RSS feed

 
Gopi Krrishna
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can i be able to call more than one servlet from another servlet? like..

res.sendRedirect("http://"+address_1+":7001/GetMemory");
res.sendRedirect("http://"+address_2+":7001/GetMemory");

here GetMemory is the servlet that returns free memory.
how can i print the output of two servlets when the user clicks "submit" button?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you should look at the include() method of the RequestDispatcher
 
Gopi Krrishna
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Satou kurinosuke,
But i think RequestDispatcher interface works on the current Servlet context. but i want to invoke two servlets in two different servers.
[ March 02, 2007: Message edited by: Gopi Krrishna ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point ! Sorry about my silly suggestion.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Http is a request/response protocol.

Response.sendRedirect works by sending a 302 or 304 response code to the browser, along with a Location header that contains the URL of the page or sit e to which you want send the user.

Firing two off in rapid succession (if it doesn't cause an IllegalStateException on the server) would not be very useful, the second one would be ignored.

What are you trying to do?
Maybe if you describe your requirements someone can suggest a better alternative.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use HttpURLConnection to read the output from those pages, and then include them in the page you are generating.
 
Gopi Krrishna
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
You could use HttpURLConnection to read the output from those pages, and then include them in the page you are generating.


Can you be able to explain how to use HttpURLConnection class?
Or else can you suggest good site that explains that? Thanks in advance
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In many cases you might even get away without using an explicit connection. It might be as simple as:


[ March 02, 2007: Message edited by: Ulf Dittmer ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!