Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problems with Apache HttpClient  RSS feed

 
Samuel Goldschmidt
Greenhorn
Posts: 15
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a strange problem here with my application.
What the application should do: Download the source code of web pages and save them to a local file.
To do this, I use the Apache httpclient library.

My problem:
The downloader is a Swing application created with NetBeans and its GUI Builder.
To download the web page, some lines of code using httpclient are needed.
When the "Start download" button is pressed, the page should be downloaded.
It's just, if I just put the download code in the ActionListener.actionPerformed(...) method of the "Start download" button (which is called when the button is pressed), it doesn't work! The thread just stops mid-flow! On the other hand, if I download something using HttpClient before the Swing application even starts, everything works fine afterwards if the button is pressed! Why does some random code completely detached from the main application influence the result of the latter?

I'm not asking you to solve my problem (but any help would be GREATLY appreciated!). But could you just try out the application for yourself and see if you can replicate the error? I attached a zip file (just rename it to something.zip) to this post containing two folders, which are two NetBeans projects. To build and execute them, you need the following libs (they are very small!):
http://gd.tuwien.ac.at/infosys/servers/http/apache/dist/httpcomponents/commons-httpclient/binary/commons-httpclient-3.1.tar.gz (add commons-httpclient-3.1.jar to your libs)
http://gd.tuwien.ac.at/infosys/servers/http/apache/dist/commons/logging/binaries/commons-logging-1.1.1-bin.tar.gz (add commons-logging-1.1.1.jar to your libs)
http://mirror.deri.at/apache/commons/codec/binaries/commons-codec-1.3.tar.gz (add commons-codec-1.3.jar to your libs).

If you aren't behind a proxy, comment out the lines in DownloaderApp.java following the
// Comment the next section (3 lines) out if you don't sit behind a proxy
comment.

If you would like to investigate further, please look inside DownloaderView.java . The thread hangs after the comment.

Any help appreciated! Thanks in advance,
Sam
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

I have deleted the attachment you posted, since we don't want to host zip files of unknown content. Masquerading it as a .jpg file to circumvent the restriction to image files is not a really nice thing to do.

If you have a short code section you can post it here. If you can't shorten it down for some reason then you need to find some other place to make it public; you can then link to it from your post here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!