| | |
URLConnection problem
![]() |
I`m trying to compile a small program for authentication on a torrent site but when it reaches the setRequestProperty() line throws an exception:
Exception in thread "main" java.lang.IllegalStateException: Already connected
at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(Unknown Source)
at MovieCrawler.main(MovieCrawler.java:22)
I understand that something is already connected! How can I disconnect before using this method;
here is the code:
pls help, I`ve spent several hours finding/creating an working authentication method... and this is my "greate" result
Exception in thread "main" java.lang.IllegalStateException: Already connected
at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(Unknown Source)
at MovieCrawler.main(MovieCrawler.java:22)
I understand that something is already connected! How can I disconnect before using this method;
here is the code:
JAVA Syntax (Toggle Plain Text)
import java.net.*; import java.io.*; public class MovieCrawler { public static void main(String[] args) throws Exception { URL url = new URL("http://www.torrentleech.org/login.php"); URLConnection uCon = url.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(uCon.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close(); //for (int i=0;i<20;i++) // System.out.println(uCon.getHeaderFieldKey(i)+": "+uCon.getHeaderField(i)); //System.out.println("kaaaaaaaaaaaaaa: "+uCon.getRequestProperty("Cookies")); String uspass = "***:***"; uCon.setRequestProperty("Authorization","Basic"+uspass); uCon.connect(); BufferedReader in2 = new BufferedReader(new InputStreamReader(uCon.getInputStream())); inputLine = ""; while ((inputLine = in2.readLine()) != null) System.out.println(inputLine); in2.close(); } }
pls help, I`ve spent several hours finding/creating an working authentication method... and this is my "greate" result

I consider rude to come here and ask for help on project for illigal activities.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- Problem with Windows Update and WinXP (Web Browsers)
- Installing Windows 98 On VMware. Floppy problem (Windows 95 / 98 / Me)
- Windows XP keeps restarting since a new video card (Windows NT / 2000 / XP)
- Redhat Linux 6.2 - ipop3d problem? (*nix Software)
- Problem with T720 (Cellphones, PDAs and Handheld Devices)
- Connection Problems (Networking Hardware Configuration)
- Encoding (Unicode) problem in IE 6.0 (Web Browsers)
- .htaccess mod_rewrite problem (Linux Servers and Apache)
- Javascript/HTML problem!!! (JavaScript / DHTML / AJAX)
Other Threads in the Java Forum
- Previous Thread: J2me
- Next Thread: Storing Objects
| Thread Tools | Search this Thread |
-xlint add android api applet application array arrays automation bi binary blackberry block bluetooth class client code compile compiler component database developmenthelp eclipse equation error event fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide idea image int integer j2me j2seprojects java javac javaprojects jetbrains jni jpanel jtable julia learningresources lego linux list login loops mac main map method methods mobile myregfun netbeans nonstatic notdisplaying number online pearl problem program project qt recursion scanner screen server set singleton sms sort spamblocker sql string swing system textfields thread threads time title tree tutorial-sample update variablebinding windows working xor






