Yashwant Balwant wrote:
> This is a servlet communication problem. I have two servlets in my
> system but on different servers and they have to be that way. Say one
> servlet on SERVER1 is a 'server' and other one on SERVER2 is 'client'. I
> want to send a request containing username-password pair from
> 'client'servlet to 'server' servlet. If client gets authenticated, I want to
> send a stream to the client.
>
> The scenario works fine with RequestDispatcher.include with both servlets
> running on same server but I don't want them on same server. I think I have
> to use HttpURLConnection but I am not sure. Could anyone please throw some
> light on this issue?
>
You are correct that you will have to use HttpURLConnection for this.
RequestDispatcher only works when the two servlets are running within the same web
application (of course that also means on the same server).
One place to start becoming familiar with URLConnection (the base class for
HttpURLConnection) is in the Networking Trail of the Java Language Tutorial
<http://java.sun.com/docs/books/tutorial>. They have examples of getting data from
a remote HTTP server using this class. If your server requires authentication, you
will also need to bone up on the HTTP/1.1 spec, and in particular how the
authentication scheme used by your server, actually work. If you're using BASIC or
DIGEST authentication, that information is found in RFC 2617, which can be located
using one of the search engines at <http://www.rfc-editor.org>.
Craig McClanahan
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets