Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Logging in with HttpClient from Apache

 
Stefan Stadler
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I've got a really big problem. It's about to logging into a https-website with HttpClient.

Here is the site : https://www-930.ibm.com/support/esc/signin.jsp

I've also prepared a testaccount for you to test, whether your ideas work or not.
Username:
1337iceskater@arcor.de

PW:
1337ic3skat3r


The task is to log in to the site and then work automatically on this page. But it fails at the login, the working process shouldn't be the greatest problem (I hope so).

So here is my code:


I hope you have an idea and/or a solution for my problem =)

Thanks in advantage

Stefan
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

That's a lot of code for doing a login. If you're planning to code real interactions with the web site I'd recommend to switch to a library like jWebUnit (or HtmlUnit, on which jWebUnit is based). That would make the task a lot easier.

If you want to stick with HttpClient, tells in more detail what "it fails at the login" means - where (and how) does the code deviate from what you expected to happen?
 
Stefan Stadler
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your fast response!

The other tool would be a possibility. But the problem is shown at this piece of code:


That means that everything seems to be ok. But if I call the page, to which the program was redirected, it tells me, that it is at the log in page and on the log in page is a comment
Your login has failed. Please try again.

I think it could be because of the cookiehandling, but it's only a guess.

If I would change the tool to one of yours, could you give me a good tutorial or a hint how I should start?

Thanks in advantage
Stefan
 
Stefan Stadler
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition:

my plan is not to test a website. I have to write an automation for creating some entries on this website.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I would change the tool to one of yours, could you give me a good tutorial or a hint how I should start?

Just to be clear, I'm not affiliated with these projects, except for having been an occasional satisfied user. For HtmlUnit, start with the "How do I..." pages on http://htmlunit.sourceforge.net/. For jWebUnit, examples can be found at http://jwebunit.sourceforge.net/quickstart.html

my plan is not to test a website.

That's what I gathered. Both tools can be used outside of any test scenario as general-purpose tools for programmatic web access.
 
Stefan Stadler
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, thanks

I try now with JWebUnit. Maybe this works :P If anybody has an idea, why the program above doesn't work, please let me know.

Thank you
Stefan
 
Narendra shah
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have worked on same application as you do have. Doing login in https site and then using other pages within the site. I have achieved the fuctionality using apache http client library using session management. Look more on session management with http client library, It will surely solve your problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic