?
Solved

How to ignnore some websites

Posted on 2004-08-01
10
Medium Priority
?
219 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:rimmer0007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 30

Accepted Solution

by:
GrandSchtroumpf earned 800 total points
ID: 11689013
just catch the exception and take appropriate action.
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 800 total points
ID: 11689021
0
 

Author Comment

by:rimmer0007
ID: 11689110
somthing like this

HTTP_UNAUTHORIZED =401;
http = (HttpURLConnection) url.openConnection();
                        
if(http.getResponseCode()== HTTP_UNAUTHORIZED )
{
      //move onto next link in vector                        
}
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 800 total points
ID: 11689224
Exactly. You don't need to define the constant - it's already defined:

if (http.getResponseCode()== HttpURLConnection.HTTP_UNAUTHORIZED )
0
 
LVL 92

Expert Comment

by:objects
ID: 11689729
you need to catch the exception anyway (to handle other failure cases).

for each link
{
   try
   {
      // attempt connection
   }
   catch (Exception ex)
   {
      // error occurred
   }
}
 
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11689737
You need to combine both techniques for proper control
0
 
LVL 92

Expert Comment

by:objects
ID: 11689752
not necessarily, plus there are *lots* of other response codes that also need to be handled.
0
 

Author Comment

by:rimmer0007
ID: 11704848
are there any quick ways of handling the other responses or am i going to have set up lots of if statements ?
0
 
LVL 92

Expert Comment

by:objects
ID: 11710722
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.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question