after executing post method on the server i get this error: HTTP/1.1 302 Found, which as i know states that there is a redirect that follows. I am trying to fill in the logon form and post it to server, after doing so, i get this redirect.
P.S. The form submit method is postback.. maybe this is a key?
P.P.S. After posting this:
__VIEWSTATE=&__EVENTTARGET=&__EVENTARGUMENT=&ctl00$tbUsername=qwerty&ctl00$tbPwd=qwerty&ctl00$chkRememberLogin=0&ctl00$cmdLogin=Login&ctl00$cmdForgetMe=Forget Me
I get this:
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="http://website/mobile/(X(1)S(lyslolvcdq13af45juum2vel))/Login.aspx?ReturnUrl=%2fsyspower3%2fmobile%2fdefault.aspx&AspxAutoDetectCookieSupport=1">here</a>.</h2>
</body></html>
Plus the set of headers:
08-02 13:48:39.084: INFO/System.out(1853): ====Header=====
08-02 13:48:39.084: INFO/System.out(1853): Cache-Control
08-02 13:48:39.084: INFO/System.out(1853): private
08-02 13:48:39.084: INFO/System.out(1853): ====Header=====
08-02 13:48:39.084: INFO/System.out(1853): Content-Type
08-02 13:48:39.084: INFO/System.out(1853): text/html; charset=utf-8
08-02 13:48:39.093: INFO/System.out(1853): ====Header=====
08-02 13:48:39.093: INFO/System.out(1853): Expires
08-02 13:48:39.093: INFO/System.out(1853): Tue, 02 Aug 2011 13:48:33 GMT
08-02 13:48:39.093: INFO/System.out(1853): ====Header=====
08-02 13:48:39.093: INFO/System.out(1853): Server
08-02 13:48:39.093: INFO/System.out(1853): Microsoft-IIS/7.5
08-02 13:48:39.093: INFO/System.out(1853): ====Header=====
08-02 13:48:39.093: INFO/System.out(1853): Set-Cookie
08-02 13:48:39.093: INFO/System.out(1853): ASP.NET_SessionId=ebmsrf45wb3mcq45qrgrfe55; path=/; HttpOnly
08-02 13:48:39.093: INFO/System.out(1853): ====Header=====
08-02 13:48:39.104: INFO/System.out(1853): X-AspNet-Version
08-02 13:48:39.104: INFO/System.out(1853): 2.0.50727
08-02 13:48:39.104: INFO/System.out(1853): ====Header=====
08-02 13:48:39.104: INFO/System.out(1853): X-Powered-By
08-02 13:48:39.104: INFO/System.out(1853): ASP.NET
08-02 13:48:39.104: INFO/System.out(1853): ====Header=====
08-02 13:48:39.104: INFO/System.out(1853): Date
08-02 13:48:39.104: INFO/System.out(1853): Tue, 02 Aug 2011 13:48:33 GMT
08-02 13:48:39.104: INFO/System.out(1853): ====Header=====
08-02 13:48:39.104: INFO/System.out(1853): Content-Length
08-02 13:48:39.104: INFO/System.out(1853): 1272
EDITED:
Now i can see the new location that I must proceed to. But here is a new problem, when i enter this new link into the browser, i get into the server(i pass login), but if I do a new request(POST) to server, then i am being thrown back to the login page…
P.S. Now i am using HttpURLConnection for the post method
That’s not an error. That’s just an informal message that there’s a redirect. Only HTTP 4nn and 5nn responses are real errors. The redirect URL is available in the HTTP
Locationheader. You, as being a web client, are obligated to send a new GET request on the URL as specified in the HTTPLocationheader.Update: So, you got a HTTP 302 response without a
Locationheader? What’s the status code of the response itself?If this is 200 and the body contains a 302 message, then it’s definitely a bug in the server side. The webserver should have returned a status code of 302 along with a
Locationheader.Update 2: So, the status code is actually 200. That’s a bug in the server side. If that website is not under your control and thus you cannot fix the server, then you need to report it to the admin/maintainer of the website. In the meanwhile, best what you could do is to extract the new location from the response body using some HTML parser and then send a new GET request on it. For example, using Jsoup: