Could you tell me how to fix the offending 3 lines try block
First, here is the offending program. The 3 lines offending try block are in Bold, Italic and Underlined.
Code:
import java.io.*;
import java.util.*;
import java.net.*;
public class WebScanner {
public static void main(String args[]) {
scanAssessorsWebSite();
scanTreasurersWebSite();
}
private static void scanAssessorsWebSite() { // WORKS !!!
try {
URL taxIDURL = new URL("http://www.maricopa.gov/assessor/ParcelApplication/Detail.aspx?ID=101-01-663");
URLConnection conn = taxIDURL.openConnection();
DataInputStream data = new DataInputStream(new BufferedInputStream(conn.getInputStream()));
System.out.println("tID = ");
}
catch (MalformedURLException e) {
System.out.println("Malformed URL: http://www.maricopa.gov/assessor/ParcelApplication/Detail.aspx?ID=101-01-663");
// _webAccessFailed = false;
}
catch (IOException e) {
System.out.println("Open Stream Exception");
}
}
private static void scanTreasurersWebSite() { // DOESN'T WORK !
String line = new String();
try {
[B][I][U] URL taxIDURL = new URL("http://treasurer.maricopa.gov/parcels/default.asp?Parcel=10101663");
URLConnection conn = taxIDURL.openConnection();
DataInputStream data = new DataInputStream(new BufferedInputStream(conn.getInputStream()));[/U][/I][/B]
}
catch (MalformedURLException e) {
System.out.println("Malformed URL: http://treasurer.maricopa.gov/parcels/default.asp?Parcel=10101663");
}
catch (IOException e) {
System.out.println("scanTreasurersWebSite - Caugh Exception " + e.toString());
}
}
}
End of WebScanner.java
Second, the output:
tID =
scanTreasurersWebSite - Caugh Exception java.io.IOException: Server returned HTTP response code: 400 for URL: http://
treasurer.maricopa.gov/Parcel/SetSession.asp?pn=10101663&tcd=1&fpn=101-01-663 1&mry=2010&sec=True&rf=False&dp=S
End of Output
Third, some comments about the difference in the 2 web sites I am trying to read (the successful try, and the unsuccessful one):
The page I succeeded in reading is
http://www.maricopa.gov/assessor/Par...?ID=101-01-663
If you typed that URL in your browser and hit enter, you will still see that URL in your browser.
The one I am unable to read is:
treasurer.maricopa.gov/parcels/default.asp?Parcel=10101663
If you typed that URL in your browser and hit enter, you will see the following URL in your browser: treasurer.maricopa.gov/Parcel/Summary.aspx
I suspect this type of redirection is causing problems for my code.
Last but not least, the plea: please reply in Java code, ideally a new try block that in some way loads the data from the Treasurer's web page, and not in Shakespearean verbiage as in "to be or not to be, that's the question", or "what you need to do is fork a semaphore that will open the URL's socket using the TPC protocol to get around the apache deamon". I have no idea how to compile and run either of the 2 previous statements.
Thanks,
Abdenour