Vasu,
You can use RequestDispatcher(URL).forward(req,res) for servlets
communication within the same server.
For cross servers, if you want the servlet 1 to finally send a response to
the client after getting the response from servlet2 you may use URL
Connection to write to the connection. Read the input stream in servlet1 and
send an appropriate response to the client.
If you wish to pass on the control from servlet1 to servlet2 use
Response.send Redirect(). From thereon the servlet 2 can process and send
the response to the client.
good luck :-)
Revathi
>From: Vasu Y <[EMAIL PROTECTED]>
>Reply-To: "A mailing list for discussion about Sun Microsystem's Java
> Servlet API Technology." <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Servlet-to-Servlet Communication
>Date: Thu, 7 Dec 2000 19:01:34 -0800
>
>I have a servlet "servlet1" which should invoke another servlet "servlet2"
>running on a different machine to get the response and pass it on to the
>client.
>i am using tomcat 4.0.
>how can i do this?
>
>I tried with the following code, but doesn't work:
>////////////////Code//////////////
>response.setContentType("text/html");
>PrintWriter out = response.getWriter();
>ServletConfig config = getServletConfig();
>ServletContext context =
>config.getServletContext();
>RequestDispatcher dispatcher =
>context.getRequestDispatcher
>("http://machine2:8080/HelloWorldExample3");
>dispatcher.forward(request, response);
>}
>
>//////////End Code ////////////////
>
>
>thanks,
>vasu
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
_____________________________________________________________________________________
Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html