aspose file tools*
The moose likes Servlets and the fly likes calling servlet from another server. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "calling servlet from another server." Watch "calling servlet from another server." New topic
Author

calling servlet from another server.

aman hindustani
Ranch Hand

Joined: Jun 15, 2006
Posts: 57
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

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
aman hindustani
Ranch Hand

Joined: Jun 15, 2006
Posts: 57
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

Joined: Apr 21, 2006
Posts: 1847
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.


42
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
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.


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Jimi Parekh
Greenhorn

Joined: Jul 30, 2006
Posts: 7
Try the following URL, You might get the solution.

http://support.novell.com/techcenter/articles/dne20030401.html
Jimi Parekh
Greenhorn

Joined: Jul 30, 2006
Posts: 7
Try with this also :

http://groups.google.com/group/ibm.software.websphere.application-server/browse_thread/thread/c162a09000624323/24c79cf31e7c13e3%2324c79cf31e7c13e3
aman hindustani
Ranch Hand

Joined: Jun 15, 2006
Posts: 57
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

Joined: Jun 15, 2006
Posts: 57
i mean servlet communication is possible between these two servlets running in two differenent servers..installed in two system...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: calling servlet from another server.