I can not open many websites

"real self" <[email protected]>
Newsgroups gmane.comp.web.httpunit.devel
Message-ID <[email protected]>
Hi, All,

I could not open many websites, but I could run your example for the
http://www.meterware.com.

I must make some mistakes somewhere. Could you please be nice to point it
out for me? Thanks.

The problem is the statement "  response = httpunitLink.click()";

Thanks.

Jiangfan


My code:
-------------------Begin--------------

package jfshi;

import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebLink;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;

public class Googlemaps {
      public static void main( String[] params ) {
            try {
                // create the conversation object which will maintain state
for us
                WebConversation wc = new WebConversation();

                // Obtain the main page on the maps google web site
                WebRequest request = new GetMethodWebRequest( "
http://www.google.com" );
                WebResponse response = wc.getResponse( request );

                // find the link which contains the string "HttpUnit" and
click it
                WebLink httpunitLink = response.getFirstMatchingLink(
WebLink.MATCH_CONTAINED_TEXT, "Adver" );
                System.out.println(httpunitLink.getURLString().toString());

                response = httpunitLink.click();//
<==========================SOME EXCEPTIONS HAPPEND HERE.


                for(int i=0;i<response.getLinks().length;i++){
                    WebLink tmp=response.getLinks()[i];
                    System.out.println(tmp.getText().toString());
                }

            } catch (Exception e) {
                System.err.println( "Exception: " + e );
                System.out.println("wrong!!");
            }
        }
}
------------------Over---------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

_______________________________________________
Httpunit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/httpunit-develop
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.