Using Java to supply username and password to login to a web site  
Author Message
amitshettyg





PostPosted: 2003-10-18 3:08:00 Top

java-programmer, Using Java to supply username and password to login to a web site Using Java, I want to supply my username and password to login to a
web site and manipulate the data on that site. Any suggestions?

Let me know if you need more information.

Thanks,
Amit.
 
Paul Lutus





PostPosted: 2003-10-18 3:31:00 Top

java-programmer >> Using Java to supply username and password to login to a web site Amit wrote:

> Using Java, I want to supply my username and password to login to a
> web site and manipulate the data on that site. Any suggestions?

Yes. I would try computer programming in Java to solve this problem.

What reply did you expect to such a bread inquiry, with no posted code or
details?

> Let me know if you need more information.

Let me know when you realize how one posts about a matter such as this.

--
Paul Lutus
http://www.arachnoid.com

 
Chris Smith





PostPosted: 2003-10-18 6:06:00 Top

java-programmer >> Using Java to supply username and password to login to a web site Amit wrote:
> Using Java, I want to supply my username and password to login to a
> web site and manipulate the data on that site. Any suggestions?

Can you provide more information about the web server? Is it expecting
a form login? HTTP basic authentication? HTTP digest authentication?
If it's not form login, then you can send an unauthenticated request,
and get the type of authentication required back from the response
headers. Form login is not designed to be accessible to machines, and
requires human intelligence to figure it out from scratch, so you'd need
to build in some knowledge (particularly, the names of the various
fields).

Incidentally, if you want to do the HTTP auth bit in a long-term
maintainable way, I'd take a good strong look at HttpClient from Jakarta
Commons and abandon URLConnection immediately (assuming you were looking
at it in the first place).

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
 
amitshettyg





PostPosted: 2003-10-20 23:03:00 Top

java-programmer >> Using Java to supply username and password to login to a web site Chris Smith <email***@***.com> wrote in message news:<email***@***.com>...
> Amit wrote:
> > Using Java, I want to supply my username and password to login to a
> > web site and manipulate the data on that site. Any suggestions?
>
> Can you provide more information about the web server? Is it expecting
> a form login? HTTP basic authentication? HTTP digest authentication?
> If it's not form login, then you can send an unauthenticated request,
> and get the type of authentication required back from the response
> headers. Form login is not designed to be accessible to machines, and
> requires human intelligence to figure it out from scratch, so you'd need
> to build in some knowledge (particularly, the names of the various
> fields).

Chris, Thanks for the reply.

What I am trying to do is to retrieve and save a page from a website.
The website has a login page which is a form. When I type the url for
any page, it returns the login page. i want to send the username and
password using my Java program, so that it will return the actual
page, rather than the redirected login page. Is it possible to submit
the login form and then access the required page.
>
> Incidentally, if you want to do the HTTP auth bit in a long-term
> maintainable way, I'd take a good strong look at HttpClient from Jakarta
> Commons and abandon URLConnection immediately (assuming you were looking
> at it in the first place).
 
 
Chris Smith





PostPosted: 2003-10-20 23:17:00 Top

java-programmer >> Using Java to supply username and password to login to a web site Amit wrote:
> What I am trying to do is to retrieve and save a page from a website.
> The website has a login page which is a form. When I type the url for
> any page, it returns the login page. i want to send the username and
> password using my Java program, so that it will return the actual
> page, rather than the redirected login page. Is it possible to submit
> the login form and then access the required page.

Okay, you need to first examine the login page, and find out some things
about it:

1. What is the name of the form field used for the username?
2. What is the name of the form field used for the password?
3. What is the URL used to submit the form (the "action")?
4. What HTTP "method" is used to submit the form?
5. Are there any extra form parameters expected by the server?

Once you know this, you can build an appropriate HTTP request to
simulate the form submission. Once you've submitted the form, chances
are you need to handle cookies to actually remain logged in to the
server. For *all* of this stuff (from building form parameters into an
HTTP request to maintaining state with cookies), Jakarta Commons
HttpClient will make your life much easier.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
 
amitshettyg





PostPosted: 2003-10-21 22:52:00 Top

java-programmer >> Using Java to supply username and password to login to a web site Chris, Thanks for your help, I had a look at Jakarta Commons
HttpClient, it looks like it has what I need. I think it should work.
Thanks again for your help.

Amit.

Chris Smith <email***@***.com> wrote in message news:<email***@***.com>...
> Amit wrote:
> > What I am trying to do is to retrieve and save a page from a website.
> > The website has a login page which is a form. When I type the url for
> > any page, it returns the login page. i want to send the username and
> > password using my Java program, so that it will return the actual
> > page, rather than the redirected login page. Is it possible to submit
> > the login form and then access the required page.
>
> Okay, you need to first examine the login page, and find out some things
> about it:
>
> 1. What is the name of the form field used for the username?
> 2. What is the name of the form field used for the password?
> 3. What is the URL used to submit the form (the "action")?
> 4. What HTTP "method" is used to submit the form?
> 5. Are there any extra form parameters expected by the server?
>
> Once you know this, you can build an appropriate HTTP request to
> simulate the form submission. Once you've submitted the form, chances
> are you need to handle cookies to actually remain logged in to the
> server. For *all* of this stuff (from building form parameters into an
> HTTP request to maintaining state with cookies), Jakarta Commons
> HttpClient will make your life much easier.