You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Yoav Shapira <sh...@mpi.com> on 2001/10/25 15:33:15 UTC

Can't open InputStream to manager??

Hi there,

I have a servlet that tries to do something like:

URL url = new
URL("http://manageruser:managerpassword@myserver.mydomain:myport/manager/list");
URLConnection con = url.openConnection();
BufferedReader bin = new BufferedReader(new
InputStreamReader(con.getInputStream);

The third line throws an exception.  The connection itself is fine,
I can call stuff like con.getContentLength() and it works (correctly)
without a problem.  

Is the manager app coded specifically to disallow opening stream to it?
Has anyone else tried/encountered something like this?

Thanks!

Yoav Shapira
Millennium Pharmaceuticals

Re: Can't open InputStream to manager??

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 25 Oct 2001, Yoav Shapira wrote:

> Date: Thu, 25 Oct 2001 09:33:15 -0400
> From: Yoav Shapira <sh...@mpi.com>
> Reply-To: tomcat-user@jakarta.apache.org
> To: tomcat-user@jakarta.apache.org
> Subject: Can't open InputStream to manager??
>
> Hi there,
>
> I have a servlet that tries to do something like:
>
> URL url = new
> URL("http://manageruser:managerpassword@myserver.mydomain:myport/manager/list");
> URLConnection con = url.openConnection();

Try adding:

  con.setDoInput(true);
  con.connect();

here.

> BufferedReader bin = new BufferedReader(new
> InputStreamReader(con.getInputStream);
>
> The third line throws an exception.  The connection itself is fine,
> I can call stuff like con.getContentLength() and it works (correctly)
> without a problem.
>
> Is the manager app coded specifically to disallow opening stream to it?
> Has anyone else tried/encountered something like this?

There's nothing special in Manager that would do this (although you're
going to have to include an appropriate "Authorization" header in your
request to bypass the 401 response asking for BASIC authentication).  It's
more likely to be related to the order of calls on your URLConnection --
see the javadocs for java.net.URLConnection (and the Networking Trail in
the online tutorial at <http://java.sun.com/docs/books/tutorial>) for more
information on this.

>
> Thanks!
>
> Yoav Shapira
> Millennium Pharmaceuticals
>

Craig