|
|
Setting the User-Agent string in the Jakarta Commons HttpClientJeffrey P. Bigham |
|
Related ArticlesRelated Ads |
The Jakarta Commons HttpClient is an incredibly useful tool put out by the Apache Jakarta Project. It basically functions as a self-contained little web browser with a programmatic interface. One thing that you might need to do to get websites to respond to you like you expect is to trick them into thinking that you're using a more traditional browser like Internet Explorer or Netscape's Firefox. To do this, you'll have to change the user-agent string that the HttpClient displays when it sends requests. The following example code shows how to easily do this:
In this example, we're pretending to be Internet Explorer 6.0 running on Windows XP, but your HttpClient can pretend to be whatever browser you want. There's a handy list of user-agent strings on Wikipedia. More information about the Jakarta Commons Project and HttpClient can be found on the Jakarta Commons Website. |
|
|
|
||