Re: Not able to login
"Maruthi R Janardhan" <[email protected]>
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, Your code looks correct, not much I can suggest. However, here is something you can try. First up, the first request can be made a GetMethodRequest (That simulates the browser correctly) Secondly if you don't have access to server debugging, you should use a tool like TCPMON (https://tcpmon.dev.java.net/) or Ethereal to make sure that the user and password parameters are actually being sent to the server. This is the best way to debug. Compare the HtpUnit interactions with that of a natural browser interaction by listening to the network. You will surely find the difference and hence the problem. Alternatively you can debug on the server about what is happening to the request processing (Check if params are coming right). All the best Maruthi _____ From: [email protected] [mailto:[email protected]] On Behalf Of Prabudas varadarajan Sent: Wednesday, January 10, 2007 4:40 PM To: [email protected] Subject: Re: [Httpunit-develop] Not able to login Hi, Thanks a lot for your response. This my code , using which i am trying to login to a ASP application. The login fails and asks for relogin. It will be so helpful if the issue is solved. import com.meterware.httpunit.* ; public static void main(String[] args) throws Exception { WebConversation wc = new WebConversation(); HttpUnitOptions.setLoggingHttpHeaders(true); WebRequest request = new PostMethodWebRequest( " http://164.99.162.150/admin/Login.aspx"); ClientProperties cp = ClientProperties.getDefaultProperties(); cp.setAcceptCookies(true); cp.setAcceptGzip(true); WebResponse response = wc.getResponse( request ); WebForm[] forms = response.getForms(); // getting the login form WebForm loginForm = forms[0]; loginForm.setParameter("Password","novell"); loginForm.setParameter("UserName","admin"); SubmitButton submitButton = loginForm.getSubmitButtons()[0]; //getting the submit Button WebResponse firstPage = loginForm.submit(submitButton); //submitting the form } } On 1/10/07, Prabudas varadarajan <[email protected]> wrote: HI, This is the first time using httpuit. I am trying to login to a page, which is done throgh Java Script. I am acceppting cookies by using the following code : ClientProperties cp = ClientProperties.getDefaultProperties (); cp.setAcceptCookies(true); cp.setAcceptGzip(true); Also removed js.jar to avoid javascript issues. Still i am not able to login and getting redirected to login again page. Can any one kinldy help on this. Thanks, Prabu This is the header output of the conversation : Connecting to 164.99.162.150 Sending:: POST http://164.99.162.150/admin/Login.aspx Sending:: User-Agent: httpunit/1.5 Sending:: Accept-Encoding: gzip Sending:: Content-Type: application/x-www-form-urlencoded Received from http://164.99.162.150/admin/Login.aspx Header:: HTTP/1.1 200 OK Header:: Date: Wed, 10 Jan 2007 10:49:27 GMT Header:: Server: Apache/2.2.0 (Linux/SUSE) Header:: Content-Length: 3952 Header:: Cache-Control: private Header:: Set-Cookie: ASPSESSION=DDA5E08D230BD2B1BBB1DDD1; path=/admin Header:: Set-Cookie: test=True; path=/; expires=Fri, 09 Feb 2007 10:49:27 GMT Header:: Keep-Alive: timeout=15, max=100 Header:: Connection: Keep-Alive Header:: Content-Type: text/html; charset=utf-8 1 Connecting to 164.99.162.150 Sending:: POST Login.aspx Sending:: User-Agent: httpunit/1.5 Sending:: Cookie: ASPSESSION=DDA5E08D230BD2B1BBB1DDD1; test=True Sending:: Accept-Encoding: gzip Sending:: Referer: http://164.99.162.150/admin/Login.aspx Sending:: Content-Type: application/x-www-form-urlencoded Received from http://164.99.162.150/admin/Login.aspx Header:: HTTP/1.1 302 Found Header:: Date: Wed, 10 Jan 2007 10:49:28 GMT Header:: Server: Apache/2.2.0 (Linux/SUSE) Header:: Location: /admin/Login.aspx?MessageType=Error%3a&MessageText=Your+session+has+been+clo sed.+Please+log+in. Header:: Content-Length: 210 Header:: Cache-Control: private Header:: Keep-Alive: timeout=15, max=99 Header:: Connection: Keep-Alive Header:: Content-Type: text/html; charset=utf-8 Connecting to 164.99.162.150 Sending:: GET /admin/Login.aspx?MessageType=Error%3a&MessageText=Your+session+has+been+clo sed.+Please+log+in. Sending:: User-Agent: httpunit/1.5 Sending:: Cookie: ASPSESSION=DDA5E08D230BD2B1BBB1DDD1; test=True Sending:: Accept-Encoding: gzip Sending:: Referer: http://164.99.162.150/admin/Login.aspx Received from http://164.99.162.150/admin/Login.aspx?MessageType=Error%3a <http://164.99.162.150/admin/Login.aspx?MessageType=Error%3a&MessageText=You r+session+has+been+closed.+Please+log+in> &MessageText=Your+session+has+been+closed.+Please+log+in. Header:: HTTP/1.1 200 OK Header:: Date: Wed, 10 Jan 2007 10:49:28 GMT Header:: Server: Apache/2.2.0 (Linux/SUSE) Header:: Content-Length: 4156 Header:: Cache-Control: private Header:: Set-Cookie: ASPSESSION=4E2B89C313E9BE9B59013A78; path=/admin Header:: Set-Cookie: test=True; path=/; expires=Fri, 09 Feb 2007 10:49:28 GMT Header:: Keep-Alive: timeout=15, max=98 Header:: Connection: Keep-Alive Header:: Content-Type: text/html; charset=utf-8 ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Httpunit-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/httpunit-develop