Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Using Java to supply username and password to login to a web site

Reply
Thread Tools

Using Java to supply username and password to login to a web site

 
 
Amit
Guest
Posts: n/a
 
      10-17-2003
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.
 
Reply With Quote
 
 
 
 
Paul Lutus
Guest
Posts: n/a
 
      10-17-2003
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

 
Reply With Quote
 
 
 
 
Chris Smith
Guest
Posts: n/a
 
      10-17-2003
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
 
Reply With Quote
 
Amit
Guest
Posts: n/a
 
      10-20-2003
Chris Smith <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)4.net>...
> 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).

 
Reply With Quote
 
Chris Smith
Guest
Posts: n/a
 
      10-20-2003
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
 
Reply With Quote
 
Amit
Guest
Posts: n/a
 
      10-21-2003
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 <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)4.net>...
> 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.

 
Reply With Quote
 
hiren339in hiren339in is offline
Junior Member
Join Date: Nov 2007
Posts: 1
 
      11-11-2007
Hi Chris
I saw the site and found it useful.If u have a sample could u please send it sos that I could test it on a url.
 
Reply With Quote
 
anurahim anurahim is offline
Junior Member
Join Date: Oct 2008
Posts: 1
 
      10-17-2008
Can I have some sample code using org.apache.http for submitting the username, password and some other parameters the server needs to login to a website from another site
 
Reply With Quote
 
Priyank Priyank is offline
Junior Member
Join Date: Oct 2011
Posts: 1
 
      10-13-2011
I want to move a bit ahead.
Acutally, on daily basis, I have to open an internal website,loginto that, navigate toa
link/page,export an excel sheet and do processing.Can I go ahead to automate the same
through Java Program.
[Note : I can't directly access Database for that excel sheet data]
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
: how to supply login/password to a web site zigzagdna Java 7 02-18-2012 04:30 PM
Newsserver login username and password in Thunderbird 2 Ola V Firefox 4 03-01-2008 12:26 AM
Javamail login username and password same email problem Thet Aung Min Latt Computer Security 0 11-16-2007 08:19 AM
How to interactively sending the username/password to login using ssh cyrusgreats@gmail.com Perl Misc 4 10-27-2007 02:13 AM
Login script (save username and password somewhere) Arjen ASP .Net 2 04-18-2004 05:33 PM



Advertisments