views:

147

answers:

3

hi,

I would like to know if it is possible to maintain an authentication (like a session with login and password in php) on a website from a java program, and if anyone had any lead on the subject or some reading for me, that would be great.

thanks

A: 

Here is a simple tutorial on authentication for JSP...http://www.roseindia.net/mysql/loginauthentication.shtml

W_P
I think the OP wants to write a java app that logs into a php web app, and requests a bunch of pages while remaining logged in.
klausbyskov
ah, i missed the 'php' part...guess i should rba (read before answering)
W_P
yep claus, that's right. Excatly my purpose.thanks for your explanation, do you have any tuto for that?
Sephy
@Paul, well, the question isn't very clear either, but rba seems like a good general strategy ;-)
klausbyskov
Roseindia? Yuck.
BalusC
great guys, thanks for your help, I'll have a look at all of that tonight but it's pretty clear now
Sephy
+4  A: 

You can use the HttpClient class. Once you have authenticated with the website the server will send you a cookie that you have to send with each successive request in order for the server to think that you are logged in.

klausbyskov
+2  A: 

all you need is cookies, and java URLConnection. I use this all the time http://www.rgagnon.com/javadetails/java-0092.html

you use readcookies after you open a new urlconnection and writecookies when creating a new one.

Nikos