rimmer0007
asked on
How to ignnore some websites
I m storing links in vectors and then i vist each link to find out more links
sometimes a page requires a user to enter something hence i get the below exception
java.io.IOException: Server returned HTTP response code
How do i skip out these pages ? either by not storing them in the first place or if encoutered such a page skip it and move on to the next link in the vector
sometimes a page requires a user to enter something hence i get the below exception
java.io.IOException: Server returned HTTP response code
How do i skip out these pages ? either by not storing them in the first place or if encoutered such a page skip it and move on to the next link in the vector
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you need to catch the exception anyway (to handle other failure cases).
for each link
{
try
{
// attempt connection
}
catch (Exception ex)
{
// error occurred
}
}
for each link
{
try
{
// attempt connection
}
catch (Exception ex)
{
// error occurred
}
}
You need to combine both techniques for proper control
not necessarily, plus there are *lots* of other response codes that also need to be handled.
ASKER
are there any quick ways of handling the other responses or am i going to have set up lots of if statements ?
a try/catch as suggested above should pick up many of them.
or perhaps just test for successful response code and treat everything else as failure.
or perhaps just test for successful response code and treat everything else as failure.
ASKER
HTTP_UNAUTHORIZED =401;
http = (HttpURLConnection) url.openConnection();
if(http.getResponseCode()=
{
//move onto next link in vector
}