HI, I am trying to login to
http://www.ryze.com with the following code,
Code:
public class RyzeLogin {
public static void main(String args[]){
RyzeCookieListner cookieListner = new RyzeCookieListner();
HttpUnitOptions.setLoggingHttpHeaders(true);
CookieProperties.addCookieListener(cookieListner);
WebConversation webConversation = new WebConversation();
webConversation.getClientProperties().setAutoRedirect(true);
webConversation.getClientProperties().setAutoRefresh(true);
webConversation.getClientProperties().setAcceptCookies(true);
webConversation.getClientProperties().setAcceptGzip(false);
webConversation.getClientProperties().setIframeSupported(true);
webConversation.setUserAgent("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4");
try{
WebRequest webRequest = new GetMethodWebRequest("http://www.ryze.com");
WebResponse webResponse = webConversation.sendRequest(webRequest);
// Get the form and login
WebForm form = webResponse.getFormWithName("form1");
// System.out.println(form.getClassName());
form.setParameter("flogin","ajithsowkoor");
form.setParameter("fpassword","regalix");
form.submit();
webResponse = webConversation.getCurrentPage();
writeToOut(webResponse, "web/RyzeHome.html");
}catch(Exception ex){
System.out.println(ex.toString());
}
}
private static void writeToOut(WebResponse webResponse, String file) throws Exception{
InputStream is = webResponse.getInputStream();
byte[] b = new byte[is.available()];
is.read(b);
FileOutputStream fout = new FileOutputStream(file);
fout.write(b);
fout.close();
}
static class RyzeCookieListner implements CookieListener{
public void cookieRejected(String cookieName, int reason, String attribute){
try {
FileOutputStream fileOutputStream = new FileOutputStream("Log/Rejectedcookie.txt", true);
fileOutputStream.write((cookieName + ": "+ reason).getBytes());
fileOutputStream.close();
}catch (IOException ioeX) {
System.out.println(ioeX.toString());
}
}
}
}
But I could not login and the console displays the below message,
Connecting to
www.ryze.com
Sending:: GET
http://www.ryze.com
Sending:: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
Received from
http://www.ryze.com
Rhino classes (
js.jar) not found - Javascript disabled
Header:: HTTP/1.1 200 OK
Header:: Date: Tue, 23 Oct 2007 13:00:24 GMT
Header:: Server: Apache/1.3.37 (Unix) PHP/5.1.4 mod_ssl/2.8.28 OpenSSL/0.9.7a
Header:: X-Powered-By: PHP/5.1.4
Header:: Set-Cookie: PHPSESSID=deleted; expires=Mon, 23-Oct-2006 13:00:23 GMT; path=/; domain=.ryze.com
Header:: Keep-Alive: timeout=15
Header:: Connection: Keep-Alive
Header:: Transfer-Encoding: chunked
Header:: Content-Type: text/html
!!!!!!!!!!!!!!!!!!!!!
www.ryze.com
!!!!!!!!!!!!!!!!!!!!!.ryze.com
Connecting to
www.ryze.com
Sending:: GET common.
js
Sending:: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
Sending:: Cookie: PHPSESSID=deleted
Received from
http://www.ryze.com/common.js
Header:: HTTP/1.1 200 OK
Header:: Date: Tue, 23 Oct 2007 13:00:26 GMT
Header:: Server: Apache/1.3.37 (Unix) PHP/5.1.4 mod_ssl/2.8.28 OpenSSL/0.9.7a
Header:: Last-Modified: Fri, 25 Jun 2004 10:36:08 GMT
Header:: ETag: "1a6866e-7b3-40dc0018"
Header:: Accept-Ranges: bytes
Header:: Content-Length: 1971
Header:: Keep-Alive: timeout=15
Header:: Connection: Keep-Alive
Header:: Content-Type: application/x-javascript
Connecting to
www.ryze.com
Sending:: POST loginprocess.php
Sending:: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
Sending:: Cookie: PHPSESSID=deleted
Sending:: Referer:
http://www.ryze.com
Sending:: Content-Type: application/x-www-form-urlencoded
Received from
http://www.ryze.com/loginprocess.php
Header:: HTTP/1.1 200 OK
Header:: Date: Tue, 23 Oct 2007 13:00:27 GMT
Header:: Server: Apache/1.3.37 (Unix) PHP/5.1.4 mod_ssl/2.8.28 OpenSSL/0.9.7a
Header:: X-Powered-By: PHP/5.1.4
Header:: Set-Cookie: PHPSESSID=deleted; expires=Mon, 23-Oct-2006 13:00:26 GMT; path=/; domain=.ryze.com
Header:: Set-Cookie: PHPSESSID=deleted; expires=Mon, 23-Oct-2006 13:00:26 GMT; path=/; domain=.ryze.com
Header:: Expires: Thu, 19 Nov 1981 08:52:00 GMT
Header:: Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Header:: Pragma: no-cache
Header:: Set-Cookie: asclogin=ajithsowkoor; path=/; domain=.ryze.com
Header:: Set-Cookie: ascpassword=%241%24EdnDKXDF%24fTj9imbADU0fOlrdUF4l g.; path=/; domain=.ryze.com
Header:: Set-Cookie: asclogin=ajithsowkoor; path=/; domain=www.ryze.com
Header:: Set-Cookie: ascpassword=%241%24EdnDKXDF%24fTj9imbADU0fOlrdUF4l g.; path=/; domain=www.ryze.com
Header:: Keep-Alive: timeout=15
Header:: Connection: Keep-Alive
Header:: Transfer-Encoding: chunked
Header:: Content-Type: text/html
!!!!!!!!!!!!!!!!!!!!!
www.ryze.com
!!!!!!!!!!!!!!!!!!!!!.ryze.com
!!!!!!!!!!!!!!!!!!!!!
www.ryze.com
!!!!!!!!!!!!!!!!!!!!!.ryze.com
!!!!!!!!!!!!!!!!!!!!!
www.ryze.com
Can anybody kindly help me out, Plz.....
Ajit