Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need code example for entering Username and Password using HttpURLConn

Status
Not open for further replies.

thelordoftherings

Programmer
May 16, 2004
616
IL
Hello,

This is a continuation of thread269-1063133 I've popsted few days ago.
I need a code example of how to enter Username and Password for a certain site after I've opened HttpURLConnection with it. I tried looking for help on the methods setDoInput() and setDoOutput() which I beleive are the ones that with them I doing the insertion of the parameters.
If someone can please show me how to do it on an arbitrary site it would be great (lets say enter my Username and Password into my Yahoo account at the login page and then "hit" the enter to actually enter, for example). For the record, I am doing it on a site I have legal access to and is fully aware of my actions.
 
If the fields are part of a simple GET request - then you can just build up a URL normally.

However its more tricky if its a POST. I guess you could try sending the parameters on the URL - but it probably won't work - you may have to use the IO streams on the connection to successfully do it.

--------------------------------------------------
Free Database Connection Pooling Software
 
Hey sedj,

In most sites it is not in a GET method.
Isn't there a method that I can pass the URL Connection with name-value pairs? Let's say I know that the Username field is called user1. Can't I send "user1" and the Username along with it in a certain Java function?
 
No, like I said, you'll need to use the IO streams associated with that connection.

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top