• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Autologin a website

 
khaja mohideen
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 208
9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
khaja mohideen
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 208
9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic