tags:

views:

289

answers:

3

Hi community,

I have a webpage http:/ /www.somesite.de This webpage gives me a file I want to download, but before I can do it I have to login with a username and a password. Can anyone tell me where I have to look for best practices for such a problem?

Thanks in advance

Sebastian

A: 

Check out j_security_check. It's a very easy-to-implement feature of many servers.

Zack
A: 

What's your web server. If you are using Apache httpd, take a look at this,

http://httpd.apache.org/docs/2.0/howto/auth.html

ZZ Coder
it is not my webserver, it is any webserver, maybe the server where this site runs will change in time. I only know the username and password and want do programmatically login to download the page
Xelluloid
That would be tough if the web server is not under your control. There are all kinds of login schemes they can use. I don't think you will find an universal solution.If it's a form login, you just have to post the username/password in correct format and keep all the cookies. If they use HTTP Auth (looking for www-authenticate header), you probably need a library that support this. What do you use to fetch the file?
ZZ Coder
+2  A: 

so you are trying to download a file, but before you can download it you need to login?

you have 2 options:

  • Log into the website manually, take all the cookies the website gives you, and right away send the cookies using apache common http client, thereby pretending to be the session you just logged into with manually.

  • Log in using commons httpclient by sending the form data, then then accepting cookies, and using those cookies to continue the session

mkoryak