>>> Edward Curry <[EMAIL PROTECTED]> 21-Apr-00 7:45:11 PM >>>
>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.
Funny how questions follow fashion. We've had 5 or six questions like
this during thr week.
>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.
It does...
>Servlet A
> URL servletb = new URL("URL to servletB");
> URLConnection connection = servletb.openConnection();
> System.out.println("Loading 0");
> System.out.println("Sending");
> connection.setDoOutput(true);
> PrintWriter out = new PrintWriter(connection.getOutputStream());
try adding this:
out.println();
> out.println("Hello");
and this:
out.println();
> 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.
The reason is that the HTTP header is ended with a blank line and the
output ends with a blank line.
You might also need to set some request headers (use an
HttpURLConnection) for things like Content-Type.
I'm fairly sure that the URLConnection will automatically detect that
you're using HTTP and construct the correct HTTP request - but you
need to check that. If it doesn't you need to set the method of the
request according to the HTTP protocol.
Nic Ferrier
___________________________________________________________________________
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