Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I find URL after redirection?

 
the shiroi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is there anyway to find the URL of a webpage if you were
redirected?
For example, a valid URL would be http://www.vvvvvvv.com. When
I do a url.openConnection(), I am able to get the inputstream to
a web page. However, this is really a page located at http://www.vvvvvvvv.com/xxxx_home/index.jsp Is there a way of
finding out this URL from my initial URL connection?
shiroi
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Java Doc of Servlet 2.2 API, got this inforamtion. Please check if this is useful to you. THis mehtod "getRequestURI" is from HTTPServletRequest object.
Also please re-register with your first and last names.
regds
maha anna

 
the shiroi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks maha. But it dose not help me, as the redirection would be done by webservers (any webserver), I am just trying to make a urlconnection to a webserver and if at all I am redirected, how can I get the redirected url?
Thanks once again.
shiroi.
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you test? Is it like following code?. I couldn't succeed getting the redirected url with just con object. All we get is whatever we first asked for , which is www.vvvvv.com url!
Others can add to this!
regds
maha anna
 
the shiroi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai, Back again. Yes, you are rigt Maha, in all cases we get the same url that we use while creating the con obj. I tried with all the keys in the getHeaderField() but in some cases (for ex. try connecting to http://www.contakt.net or http://www.icope.com) you get the redirected url with key int = 2 i.e, under the sub heading Content-Location. But then this is not the same in all cases, there has to be a way!
Shiroi.
 
the shiroi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Also i observed that the response code(HttpURLConnectionObject.getResponseCode()) returned is not 3xx when there exists a redirection (as stated in the J2SE docs.). For example www.viviance.com (redirected to http://www.viviance.com/viviance_home/index.jsp) or www.icope.com (redirected to www.icope.com/icope/) or www.dw.org (redirected to www.dwelle.de/), strange that rCode returned is 200 and not 3xx. Any idea over this would be of great help!
shiroi.

[This message has been edited by the shiroi (edited April 04, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic