Forums Register Login

Problems with Apache HttpClient

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
Hug your destiny! And hug this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2261 times.
Similar Threads
why is log4j not working in executable jar?
Multiple jar declaration in Class-Path attribute in jar's Manifest file
Tomcat and Axis2
HttpClient Exception
Creating HTTP Post
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:53:16.