Solved

apache -> httpclient: how to send user login to web page which required usr and psswd?

Posted on 2007-03-26
13
862 Views
Last Modified: 2013-12-08
Dear experts,

I'm using log4j and httpclient from jakata in my code for login to website by automatically, but i got error message as below
 "log4j:WARN No appenders could be found for logger (org.apache.commons.httpclient.params.DefaultHttpParams)."

*My idea is want to write an application which use to log into web site eg. mail.yahoo.com or whatever and read contents or download ....

here is my code:
-------------------------

import java.io.IOException;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.params.*;
import org.apache.log4j.*;
....
.......

       public HttpClient client;
        public static Logger logger = Logger.getLogger("weblogin.class");

    //initial for client establishment
    public weblogin() {
        try {
            initCln();

        } catch (Exception e) {
            logger.error("Could not resolve to the web address !!!" +
                               e.toString());
        }
    }


    private void initCln() {
        ProxyClient pxy = new ProxyClient();
        HostConfiguration config = pxy.getHostConfiguration();

        System.out.println("----> " + config);

        client = new HttpClient();
        client.getParams().setParameter("http.useragent", "MSIE 6.0");
        client.setHostConfiguration(config);
        client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
                                        new DefaultHttpMethodRetryHandler(0, false));
    }

....
..... and i hv another class for sending login command to url
 



any useful site or sample code please?
0
Comment
Question by:ikhmer
  • 7
  • 4
  • 2
13 Comments
 
LVL 16

Expert Comment

by:suprapto45
ID: 18791235
>>"log4j:WARN No appenders could be found for logger (org.apache.commons.httpclient.params.DefaultHttpParams)."

It seems that the problem is on log4j. Have you created the log4j.properties in your classpath?

David
0
 

Author Comment

by:ikhmer
ID: 18791250
i use jbuilder, and already point to log4j library ! hmm, how could i verify if it ok ?
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 18791256
Yep,

Pointing the library (jar) file is only to make the library available to your application. However, you need to manually create the log4j.properties in your application.

Is this web application or desktop application?

David
0
 

Author Comment

by:ikhmer
ID: 18791264
it is desktop one.
0
 
LVL 16

Accepted Solution

by:
suprapto45 earned 500 total points
ID: 18791276
Okay,

Firstly, you can create a simple log4j.properties as below.

----log4j.properties-----
log4j.rootLogger=INFO, ROOT

log4j.appender.ROOT.Threshold=INFO

log4j.appender.ROOT=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ROOT.File=${user.dir}/log/BigTime.log
log4j.appender.ROOT.DatePattern='.'yyyy-MM-dd
log4j.appender.ROOT.layout=org.apache.log4j.PatternLayout
log4j.appender.ROOT.layout.ConversionPattern=%d %-5p [%t] (%F:%L) - %m%n
---------

Put it in your root path of your application and see whether it works or not.
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 18791278
You can change the name of the log file to any name that you want.

log4j.appender.ROOT.File=${user.dir}/log/[Any Name Here].log
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 86

Expert Comment

by:CEHJ
ID: 18791295
<INSTALLDIR>/src/examples/BasicAuthenticationExample.java

has an example of what you need
0
 

Author Comment

by:ikhmer
ID: 18791411
yes, log4j.property it seem ok but i got another exception --> java.net.ConnectException: Connection refused: connect

0
 
LVL 16

Expert Comment

by:suprapto45
ID: 18791434
Can you connect to Internet? Are you sure that you are not within the proxy?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 18791441
You have two problems - i'm addressing the one you've made the title of this question
0
 
LVL 16

Assisted Solution

by:suprapto45
suprapto45 earned 500 total points
ID: 18791457
0
 

Author Comment

by:ikhmer
ID: 18791489
thank for you quick support! i will look through this and let you know ... hope i could do it!

0
 
LVL 16

Expert Comment

by:suprapto45
ID: 18817506
;)

Glad I could help
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now