Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2007

Tip: Looking for answers? Try searching our database.

URL connection -- browser headers

Thread view: 
Manivannan Palanichamy - 10 Aug 2007 17:27 GMT
Hi
I am writing a java url connection code to read a web page. The
intelligent web server denies the request (returns 500 error). Yes, I
know the reason -- the web server identifies my java client as a robot/
spam program. Is there any way to pass the browser headers like ,
Accept-Language: en ?
 I know I can pass these using java socket, but is there anyway to
put these values in properties for URL connection?

--
Manivannan.Palanichamy (@) Oracle.com
http://mani.gw.googlepages.com/index.html
Andrew Thompson - 11 Aug 2007 01:07 GMT
...
>I am writing a java url connection code to read a web page.

URL?

>...The
>intelligent web server denies the request (returns 500 error). Yes, I
>know the reason -- the web server identifies my java client as a robot/
>spam program. Is there any way to pass the browser headers like ,
>Accept-Language: en ?

Sure, but why not ..
a) convince the site administrators to allow connections
from UA's that identify themselves as Java, or..
b) respect their wishes *not* to connect?

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Arne Vajhøj - 11 Aug 2007 03:10 GMT
> I am writing a java url connection code to read a web page. The
> intelligent web server denies the request (returns 500 error). Yes, I
[quoted text clipped - 3 lines]
>   I know I can pass these using java socket, but is there anyway to
> put these values in properties for URL connection?

URL url = new URL("http://www.foobar.com/");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE
5.01; Windows NT 5.0)");

(this is emulating Windows 2000 and IE 5.0 - you may want something
more recent)

Arne
Manivannan Palanichamy - 11 Aug 2007 11:45 GMT
On Aug 11, 7:10 am, Arne Vajh?j <a...@vajhoej.dk> wrote:
> > I am writing a java url connection code to read a web page. The
> > intelligent web server denies the request (returns 500 error). Yes, I
[quoted text clipped - 13 lines]
>
> Arne

Cool and quick idea. Haven't tried it. but, thanks in advance.

--
Manivannan.Palanichamy (@) Oracle.com
http://mani.gw.googlepages.com/index.html


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.