Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling servlet from another server.

 
aman hindustani
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello to all..

One servlet is running in my application ..in my server(it is in my system) it self..

can i call another servelt running in another application in another server(another system)..if yes...how ..please tell ..me ...

Thanks.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on what you mean by "call".

Your users can click on links or form submit buttons, generated by your servlet, that will generate requests to the other servlet.

You can also use response.sendRedirect to suggest that the user's browser make a request to that servlet.

Note: If the other servlet is under a different domain, the user's browser will most likely warn them that the form, link, or redirect is attempting to take them to another domain. This is usually in the form of a gray popup window.
 
aman hindustani
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i mean ..can i transfer my request and respose object ..to another servlet running in another domain...using RequestDispatcher..

like this..

String str ="http://remotehost:8080/RemoteApplication/RemoteServlet";

RequestDispatcher rd = getServletContext().getRequestDispatcher(str);

rd.forward(request,response); (or) rd.include(request,response);

Waiting for reply...
Thanks.
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by aman hindustani:
i mean ..can i transfer my request and respose object ..to another servlet running in another domain...using RequestDispatcher..


no. Those are specific to not just the server but the web application within that server which received the original request.
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are calling for any web resource in another server context, you have become a client and must use client code to do it. You can use HttpClient from Apache Jakarta Commons to do it.
 
Jimi Parekh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the following URL, You might get the solution.

http://support.novell.com/techcenter/articles/dne20030401.html
 
aman hindustani
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to mr ben ,mr jeroen, mr carl, mr jimi ...

but i am unable to concluded .. how to call ..servlet which is running...in other server...from our servlet..

please give some sample code or simple article url.
Thanks to all once again
 
aman hindustani
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i mean servlet communication is possible between these two servlets running in two differenent servers..installed in two system...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic