@alex:OK...私はこれであなたの提案に従ってHTTPS接続を確立することができました:
URL url = new URL("https://www.example.com/Login");
URLConnection urlConnection = url.openConnection();
urlConnection.setRequestProperty("Authorization", "Basic " + authString);
InputStream is = urlConnection.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
//then I read the input stream..
しかし、別のメソッドでこのコードを使用して別の接続を確立しようとしたとき (ログイン後に別のページに移動したとします)、URLConnection をパラメーターとして使用します。
//Below is in a method called account(URLConnection urlConnection)
URL url = new URL("https://www.example.com/account.aspx");
urlConnection = url.openConnection();
InputStream is = urlConnection.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
//again I read the input stream..
...以下の例外がスローされます...ログインする前に同じ例外が発生します.どうすれば修正できますか?
Server returned HTTP response code: 401 for URL: https://www.example.com/account.aspx