データを取得するときのように、Java経由でページのコンテンツを取得するときにページが提供する結果を使用して、Javaでログインシステムを作成しようとしています
http://localhost/java.php?un=dubking&password=password
ログイン資格情報が正しい場合、そのページはhtmlとして「true」のみを表示しますが、ifステートメントで実際に「true」を含むそのページのデータを持つ配列を使用すると、ifステートメントは機能しません。私が間違ったことをしたのですか、それともJavaでは不可能ですか?
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
class test2 {
public void calc() {
try {
URL yahoo = new URL("http://localhost/java.php?un=" + username + "&password=" + password);
BufferedReader in = new BufferedReader(
new InputStreamReader(yahoo.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
// Process each line.
String html = inputLine;
if (html == "true") {
System.out.print("You have successfully logged in.");
} else {
if (html == "false") {
System.out.println("Wrong username or password.");
}
if (html != "true" && html != "false") {
System.out.println("something went wrong.");
System.out.println(html);
}
}
}
in.close();
} catch (MalformedURLException me) {
System.out.println(me);
} catch (IOException ioe) {
System.out.println(ioe);
}
}
}