How to automlog into webside using username and password using java program

I am trying to log in to a website using password and username. What libraries i can use. I searched online and came to know that i can use Apache's commons HttpClient library to do that. I am new to this please let me know what can i use.
For starting purpose i wrote this code:
public static void main(String[] args) throws URIException {
     try {
          HttpClient client = new HttpClient();
          GetMethod method = new GetMethod("http://www.google.com");
               int returnCode = client.executeMethod(method);
               System.err.println(method.getResponseBodyAsString());
          method.releaseConnection();
          } catch (HttpException e) {
               e.printStackTrace();
          } catch (IOException e) {
               e.printStackTrace();
but this is giving me an error. please see below,
java.net.UnknownHostException: www.google.com
     at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
     at java.net.PlainSocketImpl.connect(Unknown Source)
     at java.net.SocksSocketImpl.connect(Unknown Source)
     at java.net.Socket.connect(Unknown Source)
     at java.net.Socket.connect(Unknown Source)
     at java.net.Socket.<init>(Unknown Source)
     at java.net.Socket.<init>(Unknown Source)
     at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
     at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
     at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
     at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
     at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
     at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
     at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
     at com.verizon.zoeott.ingest.PropertyFileReader.main(PropertyFileReader.java:48)
Another thing is that we use proxy to get internet connection. In internet explorer-->internet options-->LAN Settings-->using automatic configuration script to connect to the internet.
I don't know how to configure this into java program. please help.
Thanks,
amol
Edited by: 877846 on Jan 20, 2012 9:16 AM
Edited by: 877846 on Jan 20, 2012 9:21 AM

Also please let me know about how to connect internet through proxy server.As I said above, if you are using the Apache HTTP client, no we can't, as this is not an Apache forum. I also told you where to find that answer.
If on the other hand you don't want to use that client any more, setting the system properties http.proxyHost and http.proxyPort will do it for java.net.HttpURLConnection. See the Java Custom Networking tutorial for examples.

Similar Messages

  • How to retrieve WorkflowContext without passing username and password ?

    Hi,
    I have created a dynamic ApprovalGroup and inside this class i have the following private method.
    private IWorkflowContext fetchWorkflowContext() {
              IWorkflowServiceClient wfSvcClient =
                   WorkflowServiceClientFactory.getWorkflowServiceClient(WorkflowServiceClientFactory.LOCAL_CLIENT);
              ITaskQueryService queryService = wfSvcClient.getTaskQueryService();
              IWorkflowContext workflowContext;
              try {
                   workflowContext =queryService.authenticate("weblogic", "weblogic1".toCharArray(), null);
                   } catch (WorkflowException e) {
                   e.printStackTrace();
    But when i retrieve workflowContext, I have to pass username and password.As this dynamic ApprovalGroup class will be deployed on the same SOA server under D:\Oracle\Middleware111150\Oracle_SOA1\soa\modules\oracle.soa.ext_11.1.1
    I have kept wf_client_config.xml under D:\Oracle\Middleware111150\Oracle_SOA1\soa\modules\oracle.soa.ext_11.1.1\classes.
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <workflowServicesClientConfiguration
    xmlns="http://xmlns.oracle.com/bpel/services/client">
         <server name="default" default="true" excludeFromFederatedList="true">
         <localClient>
              <participateInClientTransaction>false</participateInClientTransaction>
         </localClient>
         <remoteClient>
              <serverURL>t3://localhost:8001</serverURL>
              <userName>weblogic</userName>
    <password>weblogic1</password>
              <initialContextFactory>weblogic.jndi.WLInitialContextFactory</initialContextFactory>
              <participateInClientTransaction>false</participateInClientTransaction>
         </remoteClient>
         <soapClient>
              <rootEndPointURL>t3://localhost:8001</rootEndPointURL>
              <identityPropagation mode="dynamic" type="saml">
                   <policy-references>
                   <policy-reference enabled="true" category="security" uri="oracle/wss10_saml_token_client_policy"/>
                   </policy-references>
              </identityPropagation>
         </soapClient>
         </server>
    </workflowServicesClientConfiguration>
    How to retrieve WorkflowContext without passing username and password ?
    ============================
    workflowContext =queryService.authenticate("weblogic", "weblogic1".toCharArray(), null);
    ============================
    regards.
    Edited by: user10303338 on Oct 5, 2011 1:51 AM

    Use :
    Properties prop = System.getProperties();
    prop.put("proxySet","true");
    prop.put("http.proxyHost","yourProxy");
    prop.put("http.proxyPort","8080"); // change the port
    //prop.put("https.proxyHost","yourProxy");
    //prop.put("https.proxyPort","8080"); // change the port
    Denis

  • HT4530 I just purchased an iMac and developed a user name and password.  I'm trying to install a program but can't because I forgot that information and didn't write it down.  How do I reissue a new username and password

    I just purchased an iMac and upon setting it up I initiated an username and a password.  Unfortunately I didn't write it down and now I'm trying to add software and the system won't let me because I forget that info.  How do I reissue a new usernam and password?

    Boot from your recovery partition by holding down the key combination command-R at startup. Release the keys when you see a gray screen with a spinning dial.
    When the recovery desktop appears, select Utilities ▹ Terminal from the menu bar.
    In the Terminal window, enter “resetpassword” and press return. A Reset Password window opens.
    Select your boot volume if not already selected.
    Select your username from the menu labeled Select the user account if not already selected.
    Follow the prompts to reset the password.
    Select  ▹ Restart from the menu bar.
    You should now be able to log in with the new password, but you won't be able to unlock the Keychain. If you've forgotten the Keychain password (which is ordinarily the same as your login password), there's no way to recover it. You’ll need to reset your keychain in the preferences of the Keychain Access application.

  • How to get to see the usernames and passwords for wifi logins on iPad

    How to get to see the usernames and passwords for wifi logins on iPad. 

    You can't access that on an iPad. The iPad does not have a Keychain Access type app like the Mac has. Maybe an application like iExplorer on your Mac will let you see them, but you can't see them on the iPad itself.

  • How can I changed the system username and password

    How can I changed the system username and password
    Need help urgent

    Paolo,
    If I understand his requirement good (to have system user but must be called xxxx) then that's the option.
    Well, that's obvious...Sure, but sometimes we see complicated thing but not something what is obvious...
    Also your demonstration to OP how to change user password indicate that OP-level of knowing Oracle user management is such that OP maybe need help for something what is for you or me obvious...
    Cheers!
    Message was edited by:
    Faust

  • How to read system eventlog using java program in windows?

    How to read system eventlog using java program in windows?
    is there any java class available to do this ? or any one having sample code for this?
    Your friend Zoe

    Hi,
    There is no java class for reading event log in windows, so we can do one thing we can use windows system 32 VBS script to read the system log .
    The output of this command can be read using java program....
    we can use java exec for executing this system32 vbs script.
    use the below program and pass the command "eventquery"
    plz refer cscript,wscript
    import java.io.*;
    public class CmdExec {
    public static void main(String argv[]) {
    try {
    String line;
    Process p = Runtime.getRuntime().exec("Command");
    BufferedReader input =
    new BufferedReader
    (new InputStreamReader(p.getInputStream()));
    while ((line = input.readLine()) != null) {
    System.out.println(line);
    input.close();
    catch (Exception err) {
    err.printStackTrace();
    This sample program will list all the system log information....
    Zoe

  • How to read system evenlog using java program in windows

    How to read system evenlog using java program in windows???
    is there any java class available to do this ? or any one having sample code for this?
    Your friend Zoe

    Welcome to the Sun forums.
    >
    How to read system evenlog using java program in windows???>
    JNI. (No.)
    >
    is there any java class available to do this ? or any one having sample code for this?>You will generally get better help around here if you read the documentation, try some sample code and come back with a specific question (hopefully with an SSCCE included).
    >
    Your friend Zoe>(raised eyebrow) Thank you for sharing that with us.
    Note also that one '?' denotes a question, while 2 or more generally denotes a dweeb.

  • How to uncompress zip files using java program

    hai,
    please give some sample code to decompress the zip file.
    how to uncompress zip files using java program
    thanking you
    arivarasu

    http://developer.java.sun.com/developer/technicalArticles/Programming/PerfTuning/
    Scroll down to 'Compression'

  • I couldn't access a website because I used an incorrect username and password.How do I reaccess with correct username and password. Thanks.

    Getting into Avenue5Consulting members only area, I mistakenly used my other username and password. A message came up asking if I wanted to save it and I pressed yes. This didn't open the site, but brought me back to login page. Realizing that I logged in with erroneous username and password, I checked and logged in again with the right username and password, but these were not accepted. Please help! I need to get back to the site to finish my homework!
    Will greatly appreciate your support.

    That issue can be caused by corrupted cookies.
    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    * Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove Cookies" from sites causing problems:
    * Tools > Options > Privacy > Cookies: "Show Cookies"
    *http://kb.mozillazine.org/Cookies
    *http://kb.mozillazine.org/Websites_report_cookies_are_disabled

  • How can I change the admin username and password

    how can I change the default admin adminadmin username and password for the server

    What version of Creator are you use?
    In Creator 2 Update 1, using Application Server version 8.2, you can do the following..
    1) Log into the Admin Console using the default UID/PWD
    2) Expand the tree view by following this path:
    Application Server > Configuration > Security > Realms > admin-realm
    3) Click on "Manage Users"
    4) Click on the UserID "admin"
    5) enter the new password that you would like
    6) Click on the "Save" button on the upper right side of the page.
    That should do it for you.
    Good luck

  • How-to access username and password protected Java EE Web services from ADF

    The title of this post is exactly the same as this article by Frank Nimphius:
    http://www.oracle.com/technology/products/jdev/howtos/1013/protectedws/access_protected_web_services_from_adf.htm
    The article addresses the problem of securing web services using usernames and passwords, when those web services are accessed through a proxy or a data control. In the examples, the user names and passwords are specified, whether in the code or the definition of data controls. (SKING/SKING).
    In a very common scenario, users login to reach a page, for example, A.jspx, which contains a button that calls a web service, for example displayDate. Suppose that user has logged in by username/pass of (AHUNOLD/AHUNOLD) and AHUNOLD has access to the service and the page. Is there any way to pass the logged in user name and password to the webservice ? Of course we can hard-code the username in the data control definition or proxy code, but this is just one of the thousands of users who have access to the service and the authentication is not dynamic this way.
    Hope my question is clear. Wishing you all a great Christmas.
    Farbod

    Hi Frank, and happy new year.
    Are you implying that it couldn't be done declaratively? What is your suggestion for this problem? You know the problem... As I described:
    - I need to secure my web services, so when exposed, no one from inside network or the internet, can access the web service without proper permission
    - The web services are shown as web controls on jspx pages. The user has logged in before reaching the page. It is irrelevant to ask him to enter user name and password again.
    - I have user names, passwords and roles in Oracle Internet Directory (Identity Management). It provides some APIs and I can retrieve the usernames and attempt logging in programmically. But how can I get username and password from the session in ADF application?
    I guess using SAML or certificate could be the solution, but I have a problem with SAML, described here:
    Re: Webservices Security, SAML, and Identity Management (OID)
    Best Regards,
    Farbod

  • How do I add a SITE, USERNAME, and PASSWORD to the list in - Tools/Options/Security/Saved Passwords ?

    How do I force Firefox to remember and use my username and password for a site ?

    #Tools -> Options -> Security - tick "remember passwords"
    #Log in to a website
    You should be asked to save the user name and password upon login.

  • How do I delete my Twitter username and password from iPhone 4?

    I upgraded to iOS5, and when i was setting it up I put in my username and password but I thought it was just for the App and not in the settings of the iPhone itself. Every time I delete the account under setting, it comes back! Why?
    I do not have the official Twitter app, I use Echofon.
    And every now and then my Twitter account comes back to the setting after i delete it. I really want it gone for good from the iPhone's setting.
    Can you please help me? And please provide instruction, they would be greatly appreciated. Thank you!

    Try this, I did it on an iBook that someone gave to me because it was slow.
    1. Reboot
    2. Hold apple key + s key down after you hear the chime. (command + s on newer Macs)
    3. When you get text prompt enter in these terminal commands to create a brand new admin account (hitting return after each line):
    mount -uw /
    rm /var/db/.AppleSetupDone
    shutdown -h now
    4. After rebooting you should have a brand new admin account. When you login as the new admin you can simply delete the old one and your good to go again!
    Apple stores wont reset it for you. Computer shops may charge you $50 to $200 trying to reinstall the Mac OS and failing at end.
    NOTE:  This will not work with the classic OS, only OS X.
    What this does is tricks the Mac into thinking that OS 10.? was just installed. It will play the intro video and then guide you through setting up your new account.

  • How to get weblogic logged in username and password in an MBEAN

    Hi,
    I have an MBEAN deployed under AdminServer. Want to establish a remote connection to credential Store MBean in base_domain using t3 protocol from this MBean, Which requires weblogic username password, port and host.
    What is the best way to get username and password,in an MBEans deployed in AdminServer at runtime.
    Thanks for your help in advance
    -Matz

    I don't think there is any way to get the password. What type of credential store is this and is it in the same domain?

  • HT1920 How can I recover my  iTunes Username and Password?

    Hello All,
    Kindly share with me how I might be able to recover my iTunes Username and Password?

    Was the Support Article you linked from not helpful ?
    Recovering a forgotten iTunes Store account name

Maybe you are looking for

  • Regarding file pick error in CC monitoring

    Hi My Sender Communication channel is throwing error in runtime workbench .. i have configured an FTP server in the sender side i have restarted the channel by stoping it and again started and in the Integration directory the Advanced mode the channe

  • Chrome is crashing my display (13", early 2013 rMBP)

    Hi there, The description says it all really. I bought my macbook second hand a week ago and after installing Chrome it seems to crash the display within an hour of use (if not sooner). When I transfer chrome to full-screen mode horizontal lines star

  • Variant for Archiving Program

    Hello Experts, We are doing Upgrade from 4.7 to ECC 6.0 .  We need to generate the Archive Objects for the Tables  S022,S026,S027,S033,S502 etc. My question is after this Archive /Delete  Programs Generation, Will the Variants be available or not . T

  • Compare X/Y in Develop module

    I would like to be able to do an X/Y compare in the develop module. I often attempt to color-match digital files and with images scanned from negatives and being limited to X/Y compare in Library doesn't really do me any good since there are no color

  • WebApp Custom Fields with Liquid

    With the liquid rendering engine tags in webapps have changed. For instance in the list layout I could display the name of the webapp item by using the following tag: {tag_name_nolink. With liquid I can use: {{name}} But for custom webapp fields what