Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7001209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:46:26+00:00 2026-05-27T20:46:26+00:00

I have started writing an application that gets in a certain website and gets

  • 0

I have started writing an application that gets in a certain website and gets the information in the pages in a nicer cleaner way. My first problem is getting authenticated so I could download the pages. This is the site: https://www.ims.tau.ac.il/Tal/.
It is in Hebrew but the top form goes (top to bottom): username, id number, password.

When I fill the form out and click the SUBMIT button I press F12 and see the POST message:

Request URL:https://www.ims.tau.ac.il/Tal/Login_Chk.aspx?rk=
Request Method:POST
Status Code:302 Found

Request Headersview parsed

POST /Tal/Login_Chk.aspx?rk= HTTP/1.1    
Host: www.ims.tau.ac.il    
Connection: keep-alive 
Content-Length: 82    
Cache-Control: max-age=0   
Origin: https://www.ims.tau.ac.il
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.120 Safari/535.2   
Content-Type: application/x-www-form-urlencoded    
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8    
Referer: https://www.ims.tau.ac.il/Tal/    
Accept-Encoding: gzip,deflate,sdch    
Accept-Language: en-US,en;q=0.8    
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3    
Cookie: ASP.NET_SessionId=2mi4i555jfibfb55wolrse55

Query String Parametersview URL encoded

rk:
Form Dataview URL encoded
user:MYUSERNAME
id_num:MYIDNUMBER
pass: MYREALPASSWORD
Enter.x:46
Enter.y:18
javatest:9
src:

Response Headersview parsed

HTTP/1.1 302 Found    
Date: Wed, 16 Nov 2011 21:25:46 GMT    
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET    
X-AspNet-Version: 2.0.50727    
Location: Sys/Main.aspx?id=021653167&sys=tal&rk=&dt=16/11/2011 11:25:46 PM    
Cache-Control: private    
Content-Type: text/html; charset=utf-8   
Content-Length: 207

I tried to do it by myself from pieces of code I found on other posts in the forum but I couldn’t get it to work:

public class MyTauRobot implements Runnable {

    private static final String TAG = "MyTauActivity";

    String name;
    String id;
    String pass;
    String result;

        public MyTauRobot() {
        super();
    }

    public MyTauRobot(String name, String id, String pass) {
        super();
        this.name = name;
        this.id = id;
        this.pass = pass;
    }

    @Override
    public void run() {
        HttpClient postClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost("https://www.ims.tau.ac.il/Tal/Login_Chk.aspx?rk=");
        HttpResponse response;


        try {

            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
            nameValuePairs.add(new BasicNameValuePair("user", name));
            nameValuePairs.add(new BasicNameValuePair("id_num", id));
            nameValuePairs.add(new BasicNameValuePair("pass", pass));

            httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            response = postClient.execute(httpPost);

            if(response.getStatusLine().getStatusCode() == 200) {
                HttpEntity entity = response.getEntity();

            }           

            Log.v(TAG,EntityUtils.toString(response.getEntity())); 

        } catch (Exception e) {
            Log.d(TAG, e.toString());
            Log.d(TAG, e.getCause().toString());
            }
        }
}

When I run it I get an exception.

org.apache.http.client.ClientProtocolException
11-19 22:42:48.758: D/MyTauActivity(726): org.apache.http.ProtocolException: Invalid redirect 
URI: Default.aspx?id=&rk=&src=&dt=20/11/2011 12:42:48 AM

UPDATE:
I still get an exception but I’ve found out that atlist it seems to be logging in right
the exception comes because the redirect is relative so i get “main.aspx?…”
instead of “http://www.tau.ac.il/Tal/Sys/main.aspx?…&#8221;

How do i fix it?

org.apache.http.ProtocolException: Invalid redirect URI: Sys/Main.aspx?id=021653167&sys=tal&rk=&dt=25/11/2011 8:50:56 AM
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:46:27+00:00Added an answer on May 27, 2026 at 8:46 pm

    Well, I found the solution.

    Problem was that the server was replying with relative redirects and the defaultHttpClient could not follow. This is weird since I set on the defaultHttpClient:

    this.getParams().setParameter(ClientPNames.REJECT_RELATIVE_REDIRECT, false);
    

    But since it didn’t get it to work I decided to try to make a relative address to an absolute address and I made it work.

    All you have to do is:

    1. Create a custom redirect handler and override the getLocation as follows:

      class CustomRedirectHandler extends DefaultRedirectHandler {
          @Override
          public URI getLocationURI(HttpResponse response, HttpContext context)
                  throws ProtocolException {
              response.setHeader("Location", "http://www.ims.tau.ac.il/Tal/"+ response.getFirstHeader("Location").getValue().replace(" ", "%20"));        
              return super.getLocationURI(response, context);
          }
      }
      

    where instead of “http://www.ims.tau.ac.il/Tal/” you write your own absolute base location for the files.

    For example you need http://www.google.com/index.html but the server just redirects to index.html. You put in “http://www.google.com/” in the location header and concat the server location reply just like in the code above.

    BTW the server was replying with spaces which again DefaultHttpClient had problem with so you replace spaces with %20 to get it to work.

    1. Set your default/custom HttpClient to use the new redirect handler like this:

      httpClient.setRedirectHandler(new CustomRedirectHandler());
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started writing a multilingual application for the very first time. I
I have started learning Python by writing a small application using Python 3.1 and
I have an application that is finished except for the problem i am trying
In order to get started with bindings, I'm writing a small application that converts
An ASP.Net MVC 3 application I've just started writing needs to have authentication for
I'm writing an application that is started by a 3rd party application just running
I'm writing an application that uses GDB to access information through java. Using Runtime.getRuntime.exec,
I have an application that I was writing that communicates with a third-party application
I have started writing a Macro in Visual Studio 2005 like this: Public Sub
I have just started writing my own JavaScript Framework (just for the learning experience),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.