Just wondering, is there a reason you are accessing
the file using the URL and not just reading it as you
would read any file on a server? It seems odd to open
a connection to the same server that the servlet is
sitting on in order to read a file.
--
On Sat, 24 Apr 1999 01:04:12 Craig R. McClanahan wrote:
>Formanek Gary L wrote:
>
>> Hi,
>>
>> I'm trying to read an HTML file from the server in a servlet. This is what
>> I'm doing from a method called after doPost():
>>
>> URL u = new URL("http://" + req.getServerName() + "/wms/update.htm");
>> log("before URL to open = " + u.toString());
>> URLConnection uc = u.openConnection();
>> log("after URL to open");
>> BufferedInputStream bis = new BufferedInputStream(uc.getInputStream());
>> log("after openStream");
>> byte b[] = new byte[bis.available()];
>> bis.read(b);
>> out.print(b);
>> out.flush();
>> out.close();
>>
>> Basically it doesn't get to the "after openStream". It dies on the
>> getInputStream(). This is the error I get back:
>>
>> unknown protocol: https
>>
>> This is a protected URL, but not https. I was hoping I could read an HTML
>> file on the server in the docs directory. Does anyone have any ideas why I
>> can't?
>>
>> Thanks,
>>
>> Gary
>>
>
>By "this is a protected URL", do you mean that the page would ask for a
>username/password if you accessed it with a browser? If so, you've got two
>choices:
>
>* Call "uc.setAllowUserInteraction(false)", which will disable the fact
> that your servlet engine has probably posted a username/dialog box
> on your server's console. This will probably trigger an exception,
> but that is still better than hanging.
>
>* Include an "Authorization" header in your request (using the
> URLConnection.setRequestProperty method), with the username
> and password properly encoded.
>
>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
>
HotBot - Search smarter.
http://www.hotbot.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