• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

How to get response content of a website

 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Like through java.net.URL i am trying to connect to some site like www.google.com,now i want the response send by GOOGLE in text format not in HTML.
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By just hitting the google web URL, you're going to get back HTML.

If you want more control, google has a rich toolkit of web services as well as a Java API that you can use to do pretty much whatever you want.
[ March 07, 2007: Message edited by: Bear Bibeault ]
 
ram gaurav
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply.

I have just taken example of google.com.
Like my code is :



Now just after this it gives me error.
Can you please tell us that where are we doing wrong

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you ping Yahoo from where you're running this code?

Servlet engines like Tomcat often run with a security manager, which may prohibit all kinds of activity, but particularly networking (although that doesn't seem to be the problem here).
 
ram gaurav
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply.

Actually Ping uses different protocol and HTTP is different.

Like i can simply type www.yahoo.com in my browser , it open an HTML page for , but i want the response as plain text not as HTML.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I was asking is whether you can connect to Yahoo from the machine where you're running that code. Does that mean the answer to that is "yes"? Is it the same machine on which you're running the browser? Are there any further exception in the Tomcat logs?
 
ram gaurav
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ya i can connect to yahoo.com from my browser , but when i try to connect through my Servlet it give Connection Refused exception
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am going to guess that you have some sort of security software running on that system. Many kinds of "malware" try to connect to urls for various nefarious reasons so security software may only allow outgoing connections to be made by known programs.

Bill
 
ram gaurav
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ya , that can be the reason because we are running with some firewalls in our systems.

So how to proceed with that
 
ram gaurav
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

In my previous code i have add few things



and now Connection refused error is not coming, but now HTTP 403 ( Forbidden : The server understood the request, but is refusing to fulfill it. Typically due to file access permissions on the server. )

Can you please tell me that why it is not allowing me and giving HTTP 403 error.

Thanks
Ram
 
reply
    Bookmark Topic Watch Topic
  • New Topic