This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hi i need to login a site using programmatically is it possible to do legally if yes how to do???
thanks
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35249
7
posted
0
Originally posted by mano ranjan: i need to login a site using programmatically is it possible to do legally if yes how to do?
Several things come to mind:
If this is a web app, then you can use the java.net.HttpUrlConnection class, or the Jakarta Commons HttpClient library to do this. More comfortable would be to use a package like jWebUnit, which works at the HTML level; login forms aren't different than other HTML forms.
Why are you concerned about the legality? Is this is a web site you're not supposed to access?
If this is a web site meant for people to use, then just doing the login programmatically isn't going to help much, is it? What do you hope to do with the content of whichever page gets sent after you login?
mano ranjan
Ranch Hand
Joined: Jul 12, 2007
Posts: 102
posted
0
HI Its is a site where i must login to it and read the data's from a particular page.Yes iam using URLConnection for this purpose but after providing the username and password by post action . iam getting the inputstream of this url after reading that url i still get the old login page data . but not the logged in page page.(i.e its not logged in i think).So how to login ???
thanks
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35249
7
posted
0
Please post the code and the HTML login form you're trying to emulate.
mano ranjan
Ranch Hand
Joined: Jul 12, 2007
Posts: 102
posted
0
HI
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35249
7
posted
0
This code retrieves the login page, yet there's nothing in it that would submit the login form back to the server (and then read what the server sends back after that).
If the web session involves more than just a page or two, it will be simpler to use a library like jWebUnit, rather than working with on the HTTP level like this.