• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Autologin a website

 
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.
 
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
 
Marshal
Posts: 67447
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic