aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Logging in with HttpClient from Apache Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Logging in with HttpClient from Apache" Watch "Logging in with HttpClient from Apache" New topic
Author

Logging in with HttpClient from Apache

Stefan Stadler
Greenhorn

Joined: Sep 30, 2009
Posts: 4
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
Marshal

Joined: Mar 22, 2005
Posts: 42274
    
  64
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?


Ping & DNS - my free Android networking tools app
Stefan Stadler
Greenhorn

Joined: Sep 30, 2009
Posts: 4
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

Joined: Sep 30, 2009
Posts: 4
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
Marshal

Joined: Mar 22, 2005
Posts: 42274
    
  64
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

Joined: Sep 30, 2009
Posts: 4
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

Joined: Feb 28, 2007
Posts: 51
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.


Narendra Shah -- SCJP 5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Logging in with HttpClient from Apache