Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problems in HTTPS Post Login to a form inside Iframe from Java

 
Ishan Ganeshan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am trying to login to a website https://online.firstdata.de/esp/concardis/

The problem is that the login form through which a post request is made to the server is placed inside an iframe. The url of the login form is actually a redirect link and the user is redirected to another url which then renders the after login page. When I make a post request to the url of this login form from java then instead of redirecting the page to the another url the post request returns an error page. Does anybody have any knowledge of how to login to a form inside an iframe which redirects to another link from Java?




 
Tim Moores
Saloon Keeper
Posts: 3326
61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what the problem is, but if this was my problem, I'd use the HtmlUnit library - IMO the best Java library for programmatic web access.
 
Ishan Ganeshan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply. Problem is that my post request to the login form is rejected as the url that i post to is a redirect link to another url. It logs in my correctly when i do from browser. But from java some reason it is not.
 
Tim Moores
Saloon Keeper
Posts: 3326
61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HtmlUnit can be set to handle redirects (or even does so by default, I'm not sure).
 
Ishan Ganeshan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok thanks i would try with htmlunit
 
Ishan Ganeshan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried using htmlunit but since the redirect page is the same as the page containing the form inside an iframe hence it enters into an infinite loop. This is a general problem with html unit i think. When the url of the redirect page is the same as the page from which the request originates then it enters into an infinite loop. Problem is that in my page the form is inside an iframe. Below is a brief description of problem :


I am trying to login to a web page https://online.firstdata.de/esp/concardis/ using HTMLunit library in Java. The thing is that this page contains a form inside a couple of iframes. The source of the iframe containing the form is https://online.firstdata.de/login/postlogin/UserDispatcher . When a form is submitted then one of the redirect links before the next page is rendered is also the same link as mentioned above. So, this creates an infinite loop when I use it from Java. However, when the login happens from the browser because the main source of the originating page was the link ending with /concardis the redirect link is not the same as this link and hence there is no infinite loop. How can I simulate this same behaviour from Java? Here is my code :


 
Tim Moores
Saloon Keeper
Posts: 3326
61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess would be that either cookies or the referer header are not set and/or sent correctly - both seem to be missing from the code.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!