W3C home > Mailing lists > Public > www-jigsaw@w3.org > November to December 2000

Handling Client-Side Redirection [Was: Problem in downloading a file]

From: John Philip Anderson <jpanderson_215@hotmail.com>
Date: Sat, 16 Dec 2000 19:06:03 -0000
To: aspertedison@yahoo.com
Cc: www-jigsaw@w3.org
Message-ID: <F210NIJWNDIT6bB5Rw100001581@hotmail.com>
Dear Mr. Edison Aspert,

	I am responding to your request for Jigsaw help.  I believe that your 
problem lies in the realm of "Handling Client-Side Redirects."

	To begin, I tried accessing the URL in question (http://www.cel.com/) with 
a web browser (IE5.5).  The browser was redirected to :

So, I believe that the 302/"Moved Temporarily" message that you is actually 

	 Here is a piece of code that I use to Handle Client-Side Redirects:

		while(reply.getStatus() == 302){
		    String redirectURL = reply.getLocation();
		    request = manager.createRequest();
		    request.setURL(new URL(redirectURL));
		    reply = manager.runRequest(request);

	However, this does not all Handling Client-Side Redirects.  Sometimes, 
reply.getLocation() holds a String that looks like "/foo/bar" or "?foobar", 
as opposed to "http://foo.bar.etc"  As such, you may have to use 
request.getHost() and "cut and paste" some of these URL Strings to properly 
follow the redirections.  (I am working on such code which I hope to 
implement as a Jigsaw filter, like CookieFilter, but it is not done yet).

	I hope that this helps you.

	Truly yours,
	John Philip Anderson
	Michigan, USA


>From: Edison Aspert <aspertedison@yahoo.com>
>To: www-jigsaw@w3.org
>Subject: Prolem in downloading a file
>Date: Fri, 15 Dec 2000 13:57:40 -0800 (PST)
>I am trying to download a file using the Jigsaw API.
>Here is the code
>HttpManager manager = HttpManager.getManager() ;
>Request request = manager.createRequest() ;
>request.setMethod("GET") ;
>request.setURL(new URL("http://www.cel.com/"));
>Reply    reply = manager.runRequest(request) ;
>// Get the reply input stream that contains the actual
>InputStream in = reply.getInputStream() ;
>System.out.println("Code "+reply.getStatus());
>//printing 302
>BufferedReader bufferedReader = new BufferedReader(new
>String inputLine;
>while ((inputLine = bufferedReader.readLine()) !=
>	System.out.println(inputLine);
>	//writing to a file
>System.out.println("Reason "+reply.getReason());
>For the url http://www.cel.com/ I am getting the
>"Moved Temporarily" which is not correct.
>Please help me.
>Thanks in Advance.
>Aspert Edison
>Do You Yahoo!?
>Yahoo! Shopping - Thousands of Stores. Millions of Products.

Get your FREE download of MSN Explorer at http://explorer.msn.com
Received on Saturday, 16 December 2000 14:06:35 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:41:29 UTC