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?
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 ???
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.