• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Read data from URL - gives a weird error

 
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
- https://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.
 
We cannot change unless we survive, but we will not survive unless we change. Evolving tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic