Friday, October 12, 2012

Login, Browse and Upload In A Web Using Apache HTTPClient 4.3

This is my notes about using Apache HTTPClient library (version 4.3) to perform login, browse and upload in a website. At first I'm using an older version of jars and that makes some of my codes got deprecated warning when I upgrade the library. So here in my example I write two kind of codes, the deprecated and the new one.

Preparation
  • Download Apache HTTPClient 4.3 jars in here
  • Add the jars into your classpath project

Codes (deprecated)

You will notice that we have some deprecated problems here. They are :
  • DefaultHttpClient class
  • ClientContext class
  • MultipartEntity class
  • StringBody(String) constructor
  • FileBody(File,String) constructor 

Somehow, after trial & errors I solved the problem.
Codes (new style)

That's it. Hope my notes helps.

No comments:

Post a Comment