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.