aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Autologin a website Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Autologin a website" Watch "Autologin a website" New topic
Author

Autologin a website

khaja mohideen
Greenhorn

Joined: May 20, 2011
Posts: 12
Hi all,

I am really thankful if anyone guide me.

I have a link when i press the link it goes to a website and automatically fll the username password fields and automatically submit the button and move to logged page of that website

i use windows.navigate function,but i don't know how to take the id of username and password fields of navigate page.

Thank you all.
Tina Smith
Ranch Hand

Joined: Jul 21, 2011
Posts: 171
    
    5

I've always used HTTP POST and passed a string containing all the parameters needed for logging in. For example, the POST string to login to JavaRanch is (identifying info removed)


Try out an http debugger (I used Fiddler just now) to find your POST string.

Everything is theoretically impossible, until it is done. ~Robert A. Heinlein
khaja mohideen
Greenhorn

Joined: May 20, 2011
Posts: 12
Thank you for your reply ,
I use the post method to submit and pass the username and password in hidden boxes
,but it doesn't receive and put it in the texbox fields of navigate page.

the username and password feilds of navigate page is null

thankyou
Tina Smith
Ranch Hand

Joined: Jul 21, 2011
Posts: 171
    
    5

Using the post method allows you to skip the filling in of the username and password into the textboxes altogether.

When you normally login (via a browser) to a webpage, the sequence of events is something like this:
1. Go to url www.myurlhere.com
2. Fill in the login/password boxes
3. Press login
4. Browser sends a POST message containing the login/password you just filled in.

I'm suggesting you skip steps 2 and 3 since all you need is the output of those steps (which you already know) and just go straight to the POST message.

What you would do is something like this:
Create an http message to go to the url of your login page.
Set the message type to POST.
Add the login string (which will be formatted similar to &username=<username>&password=<password> but may have extra arguments (that's why I recommend an http debugger).
Send the message.

I've never actually done this in Java, only Visual Basic, so I'm not sure what the classes to use in Java are.
khaja mohideen
Greenhorn

Joined: May 20, 2011
Posts: 12
Hi,
Really thankful for your reply,but i have a code like this

<HTML>
<HEAD>
<TITLE>
Login</TITLE>
<script>
<!--
function login() {
document.form.action="www.example.com";
document.form.submit();


}
//-->
</script>
</HEAD>
<BODY onLoad="login()">
<FORM NAME="form" METHOD="post">
<input type="hidden" id="login" name="loginname" value="abc" />
<input " type="hidden" id="password" name="passwordfield" value="abc"/>
<INPUT TYPE="hidden" VALUE="enter" />
</FORM>
</BODY>
</HTML>

it goes to example.com but not fill the username and password field of example.com.

any clues
thank you
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

Of course not. You can't set the form values on another site.

If it's condoned (and only if), you should post to the form action, not the form itself.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Autologin a website
 
Similar Threads
J2EE and NTLM authentication
Session Management!!!!!!!!!!!!!!
ask for login
calling one servlet from another servlet
Java program to Login a website using url and to download a file