From: Ahmed A. <asa...@ya...> - 2013-12-13 23:40:51
|
Hi Arun, Your case works correctly with me ("POST" is written) : WebRequest request = new WebRequest(new URL("http://localhost:8080/test.jsp"), HttpMethod.POST); WebClient webClient = new WebClient(); HtmlPage page = webClient.getPage(request); System.out.println(page.asText()); --------------- test.jsp <%=request.getMethod()%> Ahmed ________________________________ From: Arun Gupta <aru...@gm...> To: Ahmed Ashour <asa...@ya...>; htm...@li... Sent: Friday, December 13, 2013 9:31 PM Subject: Re: [Htmlunit-user] NoSuchMethodError AbstractHttpClient.execute That worked. Now I'm trying to POST a request as: WebClient webClient = new WebClient(); WebRequest request = new WebRequest(new URL(base + "SecureServlet"), HttpMethod.POST); HtmlPage page = webClient.getPage(request); Wireshark shows this as GET request though. However it also shows: Accept: POST header. Any suggestions ? Arun On Thu, Dec 12, 2013 at 10:27 PM, Ahmed Ashour <asa...@ya...> wrote: > Hi Arun, > > You have an issue in your classpath. > > Please remove all HttpClient dependencies and leave only HtmlUnit, maven > automatically gets all needed dependencies. > > Yours, > Ahmed > ________________________________ > From: Arun Gupta <aru...@gm...> > To: htm...@li... > Sent: Friday, December 13, 2013 4:23 AM > Subject: [Htmlunit-user] NoSuchMethodError AbstractHttpClient.execute > > Just starting to replace HttpUnit with HtmlUnit and liking the clean > API so far. The original test source is: > > WebConversation conv = new WebConversation(); > GetMethodWebRequest getRequest = new GetMethodWebRequest(base > + "/TestServlet"); > WebResponse getResponse = conv.getResponse(getRequest); > assertTrue(getResponse.getText().contains("<title>Servlet > url-pattern in web.xml</title>")); > > > and replacing it with: > > WebClient webClient = new WebClient(); > HtmlPage page = webClient.getPage(base + "/TestServlet"); > assertEquals("Servlet url-pattern in web.xml", page.getTitleText()); > > I've added the following dependency: > > <dependency> > <groupId>net.sourceforge.htmlunit</groupId> > <artifactId>htmlunit</artifactId> > <version>2.13</version> > <scope>test</scope> > </dependency> > > But running this test gives the following error: > > java.lang.NoSuchMethodError: > org.apache.http.impl.client.AbstractHttpClient.execute(Lorg/apache/http/HttpHost;Lorg/apache/http/HttpRequest;Lorg/apache/http/protocol/HttpContext;)Lorg/apache/http/client/methods/CloseableHttpResponse; > at > com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:167) > at > com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1281) > at > com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1198) > at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:307) > at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:376) > at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:361) > > Googling asked me to add commons-codec dependency so I also added: > > <dependency> > <groupId>commons-codec</groupId> > <artifactId>commons-codec</artifactId> > <version>1.8</version> > <scope>test</scope> > </dependency> > > No cigar though. > > The original test is at: > > https://github.com/javaee-samples/javaee7-samples/blob/master/servlet/metadata-complete/src/test/java/org/javaee7/servlet/metadata/complete/TestServletTest.java > > What am I missing ? > > Arun > > -- > http://blog.arungupta.me > http://twitter.com/arungupta > > ------------------------------------------------------------------------------ > Rapidly troubleshoot problems before they affect your business. Most IT > organizations don't have a clear picture of how application performance > affects their revenue. With AppDynamics, you get 100% visibility into your > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics > Pro! > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > > ------------------------------------------------------------------------------ > Rapidly troubleshoot problems before they affect your business. Most IT > organizations don't have a clear picture of how application performance > affects their revenue. With AppDynamics, you get 100% visibility into your > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics > Pro! > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > -- http://blog.arungupta.me http://twitter.com/arungupta |