Edward Curry wrote:
> Hello,
> Ive seen servlet to servlet communication between servlets on the
> same
> webserver a number of times on this list, But i have seen Servlet to servlet
> via
> http.
>
> I want to pass an XML string between 2 servlets, ive tried to use the URL
> object
> as below, but it does not seems to call the servlet.
>
> Servlet A
>
> URL servletb = new URL("URL to servletB"); // The url works, i cut and paste
> it
> from my browser.
> URLConnection connection = servletb.openConnection();
> System.out.println("Loading 0");
>
> System.out.println("Sending");
> connection.setDoOutput(true);
>
According to the URLConnection javadocs, you have to call connection.connect()
here.
>
> PrintWriter out = new PrintWriter(
> connection.getOutputStream());
> out.println("Hello");
> out.close();
> System.out.println("Sent");
>
> ServletB
> System.out.println("LoadingB");
>
> System.out.println("Receiving");
> BufferedReader in = new BufferedReader(
> new InputStreamReader(
> request.getInputStream()));
> String inputLine;
>
> while ((inputLine = in.readLine()) != null)
> System.out.println(inputLine);
>
> in.close();
>
> Ive been banging my head off the wall for the last 2 days with this. Any
> help
> with this would be greatly appericated.
>
> All the best,
> Ed
>
Craig McClanahan
___________________________________________________________________________
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