public boolean testSite(String website_url, String enteredCID) { URL url = null; try { url = new URL("http://www.webblock.net/netBlock/sdk?NBCID="+enteredCID+"&NBURL=" + website_url); } catch (java.net.MalformedURLException ex) { jEditorPane1.setText("URL could not be formed, failure:"+website_url); return false; } HttpURLConnection connection =null; try { connection = (HttpURLConnection)url.openConnection(); } catch (java.io.IOException ex) { jEditorPane1.setText("Could not make a connection to URL:"+website_url); return false; } connection.setUseCaches(false); connection.setRequestProperty( "User-Agent","Mozilla/4.0 (compatible;MSIE 5.0)" ); connection.setRequestProperty( "accept-language","text/html" ); int responseCode = -1; String responseMessage = null; try { responseMessage = connection.getResponseMessage(); } catch (java.io.IOException ex) { /*a response of null, site is dead */ jEditorPane1.setText("Response MESSAGE could not be determined for URL :"+website_url+": "+ex.getMessage()); try { responseCode = connection.getResponseCode(); } catch (java.io.IOException ex2) { jEditorPane1.setText("Response code could not be determined for URL :"+website_url+": "+ex2.getMessage()); } connection.disconnect(); return false; } try { responseCode = connection.getResponseCode(); } catch (java.io.IOException ex) { jEditorPane1.setText("Response code could not be determined for URL :"+website_url+": "+ex.getMessage()); connection.disconnect(); return false; } jEditorPane1.setText("ResponseCode is "+responseCode); switch (responseCode){ case NB_ACCOUNT_EXPIRED: jEditorPane1.setText("Account that references NBCID has expired. Please contact WebBlock"); break; case NB_ACCOUNT_NOTFOUND: jEditorPane1.setText("Account that references NBCID was not found. Please contact WebBlock"); break; case NB_ACCOUNT_RATINGS_ERROR: jEditorPane1.setText("You have duplicated a rating in the parameters NBPASS OR NBBLOCK. Both parameters must be unique."); break; case NB_ACCOUNT_CONNECTION_REFUSED: jEditorPane1.setText("The database connection could not be opened"); break; case javax.servlet.http.HttpServletResponse.SC_OK: jEditorPane1.setText("NBURL was found in the database, with an assigned rating and was passed or as been previously visited. "); break; case javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED: jEditorPane1.setText("The account pointed to by NBCID has been disabled. This is a feature where you can close down all connections."); break; case javax.servlet.http.HttpServletResponse.SC_FORBIDDEN: jEditorPane1.setText("The site pointed to by NBURL has failed against a rating of NBBLOCK or one set in the database."); break; case javax.servlet.http.HttpServletResponse.SC_NOT_FOUND: jEditorPane1.setText("The site pointed to by NBURL was not found in the WebBlock database and has no rating attached to it."); break; } connection.disconnect(); return true; } //testSite