aspose file tools*
The moose likes Web Services and the fly likes Read data from URL - gives a weird error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Read data from URL - gives a weird error" Watch "Read data from URL - gives a weird error" New topic
Author

Read data from URL - gives a weird error

Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

We have two web portals which has a centralized login. So decided to go with simple URL sending method like this one.





The error it gives is


Also when i type the URL in browser it's working fine, means code gets invoked and DB gets processed.

Although, the code is working fine as it's been called and database operations went successful but the only thing is it doesn't return the value(think so). So please let me know where i went wrong?


Never try to be a hard-worker. Be a smart-worker.
My Blog
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
Hi. Were you able to find a solution? This type of error can occur when our code is not properly accounting for http protocol details, and some other reasons. You could try these links:

- http://stackoverflow.com/questions/2794006/java-io-filenotfoundexception-for-valid-url
- http://www.codeguru.com/forum/archive/index.php/t-41552.html
- http://forums.sun.com/thread.jspa?threadID=337084

Please let us know if the above worked. In any case, as suggested in the stackoverflow post, I have always found it a good idea to use libraries like HttpClient instead of directly invoking URL.openConnection since HttpClient takes care of a lot of minor details, accounting for different http response codes, etc. Best of luck!
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

R Srini wrote:Hi. Were you able to find a solution? This type of error can occur when our code is not properly accounting for http protocol details, and some other reasons. You could try these links:

- http://stackoverflow.com/questions/2794006/java-io-filenotfoundexception-for-valid-url
- http://www.codeguru.com/forum/archive/index.php/t-41552.html
- http://forums.sun.com/thread.jspa?threadID=337084

Please let us know if the above worked. In any case, as suggested in the stackoverflow post, I have always found it a good idea to use libraries like HttpClient instead of directly invoking URL.openConnection since HttpClient takes care of a lot of minor details, accounting for different http response codes, etc. Best of luck!


Still getting same error. I did tried all the solutions that were in the links but no use. Please let me know if there is any other workaround.
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
I have tried your code with three different URLs and this works fine:

- http://search.yahoo.com/search?p=choochootrain
- http://www.bing.com/search?q=prahlad+jani
- http://www.coderanch.com/forums/jforum?module=search&action=search&forum=51&match_type=all&sort_by=time&search_keywords=world

And I do not have the time to setup two web portals with a centralized login (which is your environment). Also, I don't understand this statement:
Although, the code is working fine as it's been called and database operations went successful but the only thing is it doesn't return the value(think so).

I get your FileNotFoundException if I change "http://search.yahoo.com/search?p=choochootrain" to "http://search.yahoo.com/serch?p=choochootrain" - i.e. change "search" to "serch", or use an invalid hostname. Other than that, it always works for me.

So my best suggestion is that you come up with a short and sweet example that I can run and duplicate the problem, or provide a URL where this problem occurs, or maybe even a small, basic Eclipse project, and attach it to your reply post. Then I can try it out. Otherwise, I can keep on guessing and never be of any help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Read data from URL - gives a weird error