Posting to a URL connection and receiving a response...please help!

Ok, here's the deal. Im trying to connect to a site, submit my username and password, and then retrieve the HTML source code for the page after I'm logged in so I can parse it and further manipulate it. So far, I'm establishing a connection and posting the info I want, but when I print the DataInputStream at the end, I keep getting the source code for the log in page, not the page after I'm logged in...so I'm guessing I'm not really getting logged in at all. I put my code below, please tell me whats wrong!! I really appriciate any help you can offer.
-DFG
import java.net.*;
import java.io.*;
import java.lang.String.*;
public class URLReader {
public static void main(String[] args) {
try {
URL url;
URLConnection urlConn;
DataOutputStream printout;
DataInputStream input;
url = new URL ("www.someURL.com");
urlConn = url.openConnection();
urlConn.setDoInput (true);
urlConn.setDoOutput (true);
urlConn.setUseCaches (false);
urlConn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
printout = new DataOutputStream (urlConn.getOutputStream ());
String content = "userid=" + URLEncoder.encode("username") +"&pass=" + URLEncoder.encode("password");
printout.writeBytes(content);
printout.flush();
printout.close();
input = new DataInputStream (urlConn.getInputStream ());
String str;
while (null != ((str=input.readLine()))) {
System.out.println (str);
input.close();
catch(MalformedURLException mue) {
System.out.println("exception");
catch(IOException ioe) {
System.out.println("exception");
catch(Exception e) {
System.out.println("exception");
}

Suppose the target website has the following pages:
index.html (contains username, password fields and posts to login.html)
login.html (processes the logging and displays the secured data).
You should be posting the username and password to login.html. If so, I suspect that the login page you are posting to is not receiving the username and password and is simply outputting the login form again. Is this what happens when you open the url in a web browser and attempt to login with no username and password?

Similar Messages

  • HT4759 ipad is disabled connect to itunes, still i have this message even after connecting and doing restor ? please help

    I am trying to log in to my ipad but still gives the message of "ipad is disabled connect to itunes, i did connect and updated with restore as instructed in itunes web. but still the same message password is needed but i cant enter password as the screen is frozen with connect to itunes?

    Hello mrhappy3,
    I recommend this section of this article named iOS: Forgotten passcode or device disabled after entering wrong passcode found here http://support.apple.com/kb/ht1212
    If you have never synced your device with iTunes
    Connecting the device may result in this error message: "iTunes could not connect to the [device] because it is locked with a passcode. You must enter your passcode on the [device] before it can be used with iTunes."
    Disconnect the USB cable from the device, but leave the other end of the cable connected to your computer's USB port.
    Turn off the device: Press and hold the Sleep/Wake button for a few seconds until the red slider appears, then slide the slider. Wait for the device to turn off.
    While pressing and holding the Home button, reconnect the USB cable to the device. The device should turn on.
    Continue holding the Home button until you see the "Connect to iTunes" screen. When this screen appears, release the Home button.
    iTunes should alert you that it has detected a device in recovery mode. Click OK, and then click Restore to restore the device.
    If this does not resolve the issue after a second try, then I would reset the iPad then then try again.
    Resetting your device
    Press and hold the Sleep/Wake button and the Home button together for at least ten seconds, until the Apple logo appears.
    From: iPhone, iPad, iPod touch: Turning off and on (restarting) and resetting
              http://support.apple.com/kb/ht1430
    All the very best,
    Sterling

  • I am about to shoot my iPod and receiver...please help

    I have a 6th generation iPod classic. I bought a Yamaha receiver with their YDS-11 dock station that is "made for iPod". I get the music through the receiver, but not playlists on my TV (the TV is run through the receiver) as is supposed to happen with compatible iPods (and the 6th generation is listed as compatible). I have a bunch of TV settings. Are these what are keeping me from getting the playlists on my TV??
    Thanks in advance for your help. I don't want to hurt my iPod, but I will do it.
    Dan

    thank you, Maria!
    anyway, the only problem i have now is that it disconnects itself after a short while -1 minute tops- and shows this "cant read or write the ipod" message.
    woohoo! that error message we've actually got some documentation on:
    -36 or "Disk cannot be read from or written to" error syncing iPod in iTunes
    ... and one of the possible causes of that error message is a software conflict.
    tracking down that particular possibility might be a pain though ... it's generally a trial and error thing. the techniques outlined in these documents might be helpful:
    Close Applications Running in the Background
    Using MSCONFIG to troubleshoot conflicts in Windows
    ... keep us posted ...
    love, b

  • Trying to login to Adobe Connect and receive the message that your account has expired.

    Trying to login to Adobe Connect and receive the message that your account has expired.

    Hi,
    The tenure of your account must have expired. You can contact Adobe Connect Support to extend your account's life.
    Thanks
    Sameer Puri

  • What is the difference between HTTPS URL connection and SSLSocket conn

    What is the difference between HTTPS URL connection and SSLSocket connection

    The difference is that they are different protocols, or rather one protocol layered over the other. If you're within a LAN you will use SSL, if it's a Web service you will use HTTPS.

  • I've tried to install flash player several different times ans each time i get a connection error message.It downloads fine and when i run the file to start install,it installs up to 5% and then i get the connection error message.Can someone please help m

    I've tried to download the flash player several different times and each time i get a connection error message.It downloads fine and when i run the file to start install, it installs up to 5% and then i get the connection error message. I've tried disabling my antivirus software, closing my browser for install and nothing.Can someone please help me? I'm using Firefox.

    Hi!
    I had the exact same issue, being on a mac. If you are on a mac and the connection error message occurs, then use this link http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player_osx.dmg
    It allows you to download it offline, which is what I used.
    Hope I was help!
    -Haroon

  • I need help I tried to use cloud backup on my iPhone 5.0.1 and after all my camera roll pictures are blurry and videos canot be played messege says URL not on this server ! Please help!! iPhone 4S, iOS 5.0.1

    I need help I tried to use cloud backup on my iPhone 5.0.1 and after all my camera roll pictures are blurry and videos canot be played messege says URL not on this server ! Please help!!
    iPhone 4S, iOS 5.0.1

    Try updating to iOS 6.1.3.

  • I have downloaded Photoshop Elements 12.  When I doubleclick on icon, it says that sign in is required.  I click sign in and it says I am not connected to the internet. Please help!  I've been trying for 3 days.

    I have downloaded Photoshop Elements 12.  When I doubleclick on icon, it says that sign in is required.  I click sign in and it says I am not connected to the internet. Please help!  I've been trying for 3 days.

    Sign in, activation, or connection errors | CS5.5 and later

  • I connect my iphone 4g on charging after some time it is complete dead and very heat up please help me.

    i connect my iphone 4g on charging after some time it is complete dead and very heat up please help me.
    helllllllllllllllllpppppppeeeeeeeee me

    There is no such thing as an iPhone 4G.

  • Trying to download songs from Itunes store. Keeps saying unable to connect. I have tried from store on computer and on phone. Please help i have weddings to do and need these songs!!!!!!!!!!!!!!!

    Trying to download songs from Itunes store. Keeps saying unable to connect. I have tried from store on computer and on phone. Please help i have weddings to do and need these songs!!!!!!!!!!!!!!!

    Hey everybody Amazon.com works perfectly and no problems so Bye, Bye Itunes fix your junk *** program and ****** customer service telling me it's my computer and connection. Oh is that also why my phone can't download them either on a seperate cell network. Nice try garbage In the time it took for them to run me around i downloaded the songs i needed via Amazon.

  • My phone has gone into recovery mode on its own.  says to connect to itunes.  i have restored it 10 times and it does nothing please help me i am out of the country and desparate

    my phone has gone into recovery mode on its own.  says to connect to itunes.  i have restored it 10 times and it does nothing please help me i am out of the country and desparate

    Open iTunes on computer. Connect iPhone to computer. If the iPhone is recognized in Recovery Mode, then Restore the Firmware. If not recognized, then hold both Home and Power Buttons until the iPhone is recognized in Recovery Mode. Usually takes about 20 seconds of holding both buttons. Restore the iPhone Firmware.

  • TS1702 After changing my phone number on iPhone, my iPad will not connect to my iMessage or FaceTime. Keeps giving me a message (could not sign in. Please check your network and try again).  Please help!!!

    After changing my phone number on iPhone, my iPad will not connect to my iMessage or FaceTime. Keeps giving me this message (Could not sign in. Please check your network and try again).  Please help!!!

    iPhone 4 and iPod touch (4th generation): Using FaceTime
    http://support.apple.com/kb/HT4319
    iPhone 4 and iPod touch (4th generation): Using FaceTime behind a firewall
    http://support.apple.com/kb/HT4245

  • I can not pair my itouch with my mac book pro version 10.6.6 .. it seems that maybe my itouch is having trouble connecting as my mac seems to pair, then waits for my itouch and it never works. please help!!

    can not pair my itouch with my mac book pro version 10.6.6 .. it seems that maybe my itouch is having trouble connecting as my mac seems to pair, then waits for my itouch and it never works. please help!!

    I am not certain this will fix your problem but I suggest you assign the printer a static IP address.
    Using the printer's front panel, select Menu > Network > WLAN > TCP/IP > Boot method, and change it to "static". Provide a static IP address that is on your LAN's subnet.
    For example, if you are using an AirPort Extreme, you might give it an IP address of 10.0.1.100. If you are using a Netgear or Linksys router that defaults to issuing 192.168.x.x addresses, you might give it an address of 192.168.1.100. That way, the printer will always "reside at the same address" on your network. If your router has the ability, you should reserve that address so that the router does not attempt to assign it to another DHCP device.
    Then, go to System Preferences > Print & Scan, and delete your existing printer with the "–" (minus) button. Add it again, using the "+" (plus) button. In the window that appears, select the IP pane, and from the Protocol menu select "Line Printer Daemon (LPD)". In the Address field type the IP address you gave your printer.
    If all goes well the "Pring Using" field will detect the printer at that address and automatically select the appropriate driver. You will see something similar to the following screenshot ("name" can be whatever you decide, and "location" is optional):
    Click Add, then you can close System Preferences.
    There are other possible reasons your printer is "not responding" which could include wireless interference from competing wireless networks, but try this "static IP" method first. It should mitigate the problem.

  • Is there a way to communicate with a GPIB device and receive the response?

    Does anyone know if there's a function that I can use to issue a command to an instrument such as a query on its status and receive its response. I've tried GPIB Write, but it just writes the command and doesn't receive the automatic response. If I use a GPIB Read right after the GPIB Write, it doesn't work! I think I'm looking for a function that sends the command to the GPIB device and then waits for the response and is capable of outputing it. Thanks for any help!
    - Jon

    I know what commands to send, I just don't know what function or vi or whatever in LabView to use in order to receive the response right after I send the command. For instance, I want to know what count the counter is currently on, and so I send the command "NN" to the counter, which tells me what count it's currently counting on. I can send the command, I just don't know how to retrieve the information of what count it's on because I don't know how to send a command and receive the response that the counter is prompted to send immediately after. Thanks for the help though!
    - Jon

  • I cannot download any apps on IPhone 5. It keeps saying "cannot connect to itunes store" even when I am perfectly logged in Itunes Store and App Store. Please help !

    I cannot download any apps on IPhone 5. It keeps saying "cannot connect to itunes store" even when I am perfectly logged in Itunes Store and App Store. Please help !

    I have this problem too since ios6 upgrade.
    4S iphone  I can connect to itunes on 3g and download an app no problem.
    I can connect to wifi no problem and use safari , facebook etc...I can connect to appstore but cannot install any apps over the wifi. 'Unable to conect to itunes'.....
    Driving me insane.............

Maybe you are looking for

  • Currency conversion doesn't work in Hyperion Planning 9.3.1

    Hello, We loaded exchange rates in Planning and when we launched a refresh of the database, exchanges rates are not transferred to essbase, as it is supposed to do according to the admin guide. Do we need to do something special to have the exchange

  • DC Build Warning

    Hi, When I build my DC I get the following warning      [Ant] java.lang.reflect.InvocationTargetException        [Ant]      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)        [Ant]      at sun.reflect.NativeMethodAccessorImpl.invok

  • How can only one Checkbox can be Selected in Table with Boolean CheckBoxes?

    I have an editable ADF table where one of the attributes is a Boolean Checkbox... and stores the value with Y or N. Is there any way where only one checkbox should be selected at the time of commit ? For example, in case its an Answers Table to a Sin

  • Rge : F110

    When we run F110,DME file is generating when we  download. We want in .csv format Please tell me the configuration or program. JABEEN

  • Spinning beach ball when changing length of midi region

    I am get a spinning beach ball when trying to change the length (with mouse) of a midi region in the arrange window. also when the beach ball stops spinning, the midi region hasn't changed its length at all. Any ideas? Thanks in advance Marcel G4 mir