>>Not exactly sure what you mean, I need to open the source code from
>>every page I access and parse it to find the links, then check the
[quoted text clipped - 11 lines]
> --
> Mike W
Correct, I don't save the pages locally, but here is a weird instance of
my error:
HttpURLConnection con = (HttpURLConnection)desti.openConnection();
int response = con.getResponseCode();
checking.setStatusCode( response );
using that last piece of code, if my desti URL is created like this:
desti = new URL("http://www.studentprograms.vt.edu");
it works fine, it connects, parses and everything, but if I create the
same URL (in reality) like this:
desti = new URL("http://www.studentprograms.vt.edu/index.php");
it wil give me the FileNotFound exception, but those two URLs are equal,
they point to the same file...
Any pointers?
thanks Ben
VisionSet - 11 Apr 2006 18:56 GMT
...
> but if I create the
> same URL (in reality) like this:
[quoted text clipped - 5 lines]
>
> Any pointers?
Stop refering to them as files they are not they are resources from your and
your codes perspective.
The URL constructor does not throw a FileNotFoundException so you need to
brush up your stack trace cause location skills!
What line is it stating as the cause of the FNF exception? There lies your
problem.
--
Mike W
Ben - 11 Apr 2006 19:08 GMT
> ...
>
[quoted text clipped - 19 lines]
> --
> Mike W
It's thrown on the line:
InputStream in = page.openStream();
where page is a URL object
Ben
Chris Uppal - 11 Apr 2006 19:40 GMT
> using that last piece of code, if my desti URL is created like this:
>
[quoted text clipped - 6 lines]
>
> it [404s]
Are those two URLs /exactly/ the ones that fail for you ? If so then there's
something odd going on, probably with your setup somewhere. I can fetch both
of them, using a program written at the pure TCP level (no HTTP libraries to
confuse the issue), with no problems at all.
Assuming that the URLs you quotes are not in fact exactly the problematic one,
then I suggest that you fire up Ethereal (you did mention that you had that, I
think) and then, using both your simple test program[*] and the browser of your
choice, attempt to fetch both. That will give you a precise record of exactly
what each HTTP client was asking for in each case (and also of any associated
gumph like acceptable encodings, languages, and whatnot). That will give you
the best pointer you are ever going to get into what's going wrong.
Come to that, do the same thing even if the above URLs /are/ exactly the
problematic ones.
-- chris
([*] you do /have/ a simple test program, I assume....)
Ben - 11 Apr 2006 19:59 GMT
>>using that last piece of code, if my desti URL is created like this:
>>
[quoted text clipped - 26 lines]
>
> ([*] you do /have/ a simple test program, I assume....)
the ones that fail are the ones that have an .(extension).
From the two URL I posted earlier, they are some of the ones I'm
testing on, the first one works but not the second. Yet they are
essentially the same.
Ben
Arvind - 11 Apr 2006 23:51 GMT
Umm it is really interesting that you can't get the inputstream at all
- Can you get the stack trace here... ?
--
Arvind
Chris Uppal - 12 Apr 2006 10:06 GMT
> the ones that fail are the ones that have an .(extension).
OK, let's get this straight.
Have you got a small test program which exhibits the problem ? (it should not
take more than a couple of minutes to write and shouldn't be more than a
handful of lines long). If not then you are just wasting time (ours as well as
your own).
Have you use Ethereal (or similar) to watch what happens when you try to
download those URLs ? If not then, again, you are just wasting time.
-- chris
Ben - 12 Apr 2006 13:11 GMT
>>the ones that fail are the ones that have an .(extension).
>
[quoted text clipped - 9 lines]
>
> -- chris
Thanks for the help, I managed to track down the error.
But yes I had test code, I use the TDD method to develop code, so I
always have test code, even before I have actual code.
Somewhere deep in my program I was adding a '/' at the end of URL so I
could have an easier time constructing absolute URL from relative URL. I
just needed to change that, and construct my URLs using the
new URL(string protocol, string host, string path) constructor instead
of the new URL(string url).
I guess that that little bit of code made the URL invalid, but when I
invoked the toString method to check it it looked just fine.
Thanks for the help again,
Ben