how to enter password once, in code, for url database access
Joined: Oct 12, 2006
i'm writing a program that needs to access details from a secure web server, it's basically person data drawn from a database that is displayed on a webpage. you are prompted to enter a password, but once you've entered the password, you pull up as many details as you like. (fully authorised to do this by the way!)
i intend to simply modify the end part of the url - looking like - .../address.asp?Mem_id=34812 - changing the number to pull up different records thru the program. once i've done this, i'm using java to convert the html and then process as xml to enter into another database. my problem is - i'm not sure exactly how to write the code for the password to be entered, here's the bit where it's going wrong...
the xml output gives me the "please enter password" page - not the info - even tho i've enetered the password seperately on the same machine. i'm guessing its something to do with ports?
could anyone give me a hint about what i need to be looking at to complete this bit of code? i've seen to servlets pop up on my searches??
thanks for reading so far, hope i've made myself clear!
Joined: Mar 22, 2005
This has nothing to do with ports. The fact that you entered the password in a browser is irrelevant for the Java application. The connection from the Java client also needs to set the password. I don't know how the helper classes you use retrieve HTML, but if there is a java.net.URLConnection (or one of its subclasses) involved somewhere, then the way to do it is described here. If not, study the API of the classes you use to see if there is a way to set the password.
(i've mispelled Kookie on purpose as it wont let me post with right spelling)
i'm thinking of taking up the url connection solution, i'm currently trying to use jakarta httpclient - which enables you to set kookies, but i keep getting a - package org.apache.commons.httpclient does not exist - error, even tho i have it installed & its dependancies!
i just cant see where i'm going wrong here... any ideas? if not, i'll have to give up on this train & go for the url connection one which does look good & i'm going to investigate anyway, thanks a lot for the cogent help
Joined: Jul 11, 2001
I notice that in your classpath, just before the httpclient entry, there seems to be some whitespace. Not sure whether that's the problem, but you might want to investigate in that direction...
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Oct 12, 2006
oh. my. god. it was the whitespace!!! Ilja, you are my hero, thank you!