Solved

How to ignnore some websites

Posted on 2004-08-01
10
196 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
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 30

Accepted Solution

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

Assisted Solution

by:CEHJ
CEHJ earned 200 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 200 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
stackato and cloud 4 85
maven module vs maven project 3 23
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 33
sql import cannot be resolved jsp 3 23
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

778 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