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

A

Amit

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

Paul Lutus

Amit said:
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.
 
C

Chris Smith

Amit said:
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
 
A

Amit

Chris Smith said:
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.
 
C

Chris Smith

Amit said:
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
 
A

Amit

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.
 
Joined
Nov 11, 2007
Messages
1
Reaction score
0
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.
 
Joined
Oct 17, 2008
Messages
1
Reaction score
0
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
 
Joined
Oct 13, 2011
Messages
1
Reaction score
0
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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top