The page redirection generally has two pages, the first page is the boot page, and the new page address is re-obtained by http-equiv = refresh using the Meta tag. So you can use a page label to explain the new page address.
We use a regular expression:
String express = "http-equiv // s * = // s * /" * refresh / "* ([^>] *) URL // s * = // s * ([^>] *)>"
To match the boot page. If you match the URL in the tag, the processed the relative address becomes an absolute address, then download this address page, this process can be iterated until no matching to the orientation tag, the last downloaded page is the final page .
Example code:
Private Boolean TryRedirect (StringBuffer SB) {
String text = sb.tostring (); // get the text
IF (Matcher.Contains (Text, Pattern)) {// If matching expressions are successful
MatchResult results = matcher.getMatch ();
String url = result.group (2); // get the new address in the label
URL = url.trim ();
IF (Url.Charat (Url.Length () - 1) == '/' ') {
URL = url.substring (0, url.Length () - 1);
}
IF (Url.Charat (Url.length () - 1) == '/ "') {
URL = url.substring (0, url.Length () - 1);
}
// Convert the relative address as absolute address
CurrentURL = com.westwind.infogate.util.urlprocess.RELATILYTOFULL (URL, CURRENTURL);
CurrentURL == NULL)
Return False;
CurrentURL = URLPROCESS.ADDHTTPHEAD (CURRENTURL);
Return True;
}
Return False;
}