Link to home
Start Free TrialLog in
Avatar of joerev
joerev

asked on

How to emulate MSIE or Netscape in URLConnection?

Hello!

I have a spider program project and there are websites
wherein I get a different webpage when using MS Internet
Explorer compared to using my Java code which
looks like the ff:
   URLConnection uc = new URLConnection("www.test.com");
   InputStream is = uc.getInputStream();
   int b = is.read();
   String pagestr = new String();
   while (b != -1){
      pagestr += /* concatenate all the read bytes */
      b = is.read();
   }

The Java code above usually gets an error message
webpage.  It's like the HTTP server detects what type of
browser is accessing their pages.  If it's not Mozilla
compatible then it gives an error message webpage.

How do I write my Java code so as the webserver thinks
that my Java code is a Mozilla compatible browser?

I've seen a couple of forum discussions in java.sun.com
about the GET header their getting but I don't know how
to make Java code to do what their discussing.

Thanks in advance!
ASKER CERTIFIED SOLUTION
Avatar of rdov
rdov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sudhakar_koundinya
sudhakar_koundinya



No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


--  points to rdov


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.