This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to enter password once, in code, for url database access

 
joyita raksit
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey there,

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...

public static void main(String args[]) {
try {
Document doc = XMLHelper.tidyHTML("http://www.********/********/address.asp?Mem_id=34812");
XMLHelper.outputXMLToFile(doc, "XML" + File.separator + "sudet.xml");
} catch (XMLHelperException xmle) {
xmle.printStackTrace();

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!
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
joyita raksit
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey,

(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!

here's my code:



& here's the classpath:

C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\Program Files\Java\jdk1.6.0\bin;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Java\jdk1.6.0\bin;C:\Program Files\Java\jdk1.6.0\bin\Tidy.jar;C:\Program Files\Java\jdk1.6.0\bin\xerces.jar;C:\Program Files\Java\jdk1.6.0\bin\xercesSamples.jar;C:\Program Files\Java\jdk1.6.0\bin\serializer;C:\Program Files\Java\jdk1.6.0\bin\xalan.jar;C:\Program Files\Java\jdk1.6.0\bin\xercesImpl.jar;C:\Program Files\Java\jdk1.6.0\bin\xml-apis.jar;C:\Program Files\Java\jdk1.6.0\bin\xsltc.jar;C:\Program Files\Java\jdk1.6.0\bin\jaxen-jdom;C:\Program Files\Java\jdk1.6.0\bin\jaxen-core;C:\Program Files\Java\jdk1.6.0\bin\saxpath.jar;C:\Program Files\Java\jdk1.6.0\bin\ant.jar; C:\Program Files\Java\jdk1.6.0\bin\commons-httpclient-3.1-beta1.jar;C:\Program Files\Java\jdk1.6.0\bin\commons-logging-api-1.1.jar;C:\Program Files\Java\jdk1.6.0\bin\commons-logging-adapters-1.1.jar;C:\Program Files\Java\jdk1.6.0\bin\commons-logging-1.1.jar;C:\Program Files\Java\jdk1.6.0\bin\commons-codec-1.3.jar;C:\Program Files\Java\jdk1.6.0\bin\junit.jar


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
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
joyita raksit
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

oh. my. god.
it was the whitespace!!!
Ilja, you are my hero, thank you!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic