mscws01, that is an own implementation of some http class, which from what I can see, you're only able to make get requests, not post.
Kevin, I'm not sure I follow. Could you give me an code example of your solution? /J On Apr 7, 5:08 pm, mscwd01 <[email protected]> wrote: > I think your asking for the final URL you are redirected to... right? > > If so this should help > nicely:http://www.example-code.com/java/http_redirect.asp > > I think you need to pay attention to this part: > > if (http.get_WasRedirected() == true) { > System.out.println("This was a redirect response"); > > System.out.println("Redirect URL:"); > System.out.println(http.finalRedirectUrl()); > > } > > Hope that helps ;) > > On Apr 7, 4:01 pm, jw <[email protected]> wrote: > > > Kevin, see my previous reply > > Thanks > > > On Apr 7, 4:47 pm, Kevin Duffey <[email protected]> wrote: > > > > As Mike says, it seems something is missing from your description. From > > > what > > > you said in your response earlier, you are being redirected. However, > > > because you are making the first request, the only way you could be > > > redirected is if the response you got back was a 301 with a Location > > > header > > > filled out. THEN, you make a second request using the Location URL that is > > > returned. If you're getting a 404, as Mike said, the initial URL you're > > > requesting is not being found. I am guessing you are not showing your > > > complete code, or being completely descriptive because well, you don't > > > want > > > to give away your secret sauce.. which I can understand. But something is > > > missing from this that is not allowing us to help you further. > > > > On Wed, Apr 7, 2010 at 7:15 AM, mike <[email protected]> wrote: > > > > On 04/07/2010 03:56 AM, jw wrote: > > > > >> Well, I'm able to set the response url in the "web service", but it's > > > >> the parameters I'm interested in... For now I've just set the response > > > >> URL towww.google.comandtheweb service adds my parameter which > > > >> giveswww.google.com/?x=1&y=2... Since this page is not available, I > > > >> get the 404 status code, not 3xx... > > > > > Er, um, 404 says that it's not there and that it doesn't know > > > > where it might be, so it's no surprise there's not a Location: > > > > header. > > > > > I suspect that you're not describing the entire process > > > > adequately for us to figure out what's going on. There is > > > > no such thing as a "response url" and a "web service" isn't > > > > especially well defined. Putting these things in terms of what > > > > HTTP 1.1 the protocol does would make it easier. > > > > > Mike, you're not conflating xml/json in the content by any chance? > > > > > Any help? > > > > >> /J > > > > >> On Apr 7, 11:41 am, mike<[email protected]> wrote: > > > > >>> On 04/07/2010 02:30 AM, jw wrote: > > > > >>>> Hi, thanks for the idea, but it didn't help. > > > > >>>> response.getHeaders("Location")[0] gives me null. I've also tried to > > > >>>> print all header keys and vaules, and none of them are Location. > > > > >>> Are you sure you're actually getting a 3xx code back from the > > > >>> http response? A 301 without a Location header would be bogus. > > > > >>> You might try using a network sniffer like ethereal to see the > > > >>> actual network traffic going by too. > > > > >>> Mike > > > > >>>> Any other ideas? > > > > >>>> /J > > > > >>>> On Apr 7, 11:12 am, mike<[email protected]> wrote: > > > > >>>> On 04/07/2010 12:40 AM, jw wrote: > > > > >>>> Hi all, > > > > >>>> thanks for your time and sorry that I wasn't clear enough. > > > > >>>> I'm making a http post request to a web page which redirects me to > > > >>>>>> different urls depending on the accuracy of my parameters sent in > > > >>>>>> the > > > >>>>>> request. This means that if I do it correct, I'll get redirected to > > > >>>>>> for examplewww.google.comwithaquerystringthatI need to get > > > >>>>>> (www.google.com?x=1y=2). Maybe that's not the response url, but I > > > >>>>>> don't now how to describe it. It's not the same as the request url > > > >>>>>> anyway. > > > > >>>> I'm able to get the response status code from the repsonse object, > > > >>>>>> which is ok, and I'm also able to get the html (content) of the > > > >>>>>> response. I just need to know what url I was redirected to. Does > > > >>>>>> this > > > >>>>>> help you? I'm very thankful for all help > > > > >>>> sounds like you want to use HttpResponse.getHeaders("Location") > > > > >>>> Mike, it returns an array, but there should only be one if it > > > >>>> redirected > > > > >>>> /J > > > > >>>> On Apr 7, 5:31 am, Kevin Duffey<[email protected]> wrote: > > > > >>>> There isn't a response URL that is any different than the request > > > >>>> URL. > > > >>>>>>> It's > > > >>>>>>> not as if the server appends a bunch of stuff to the URL you > > > >>>>>>> submit > > > >>>>>>> the > > > >>>>>>> request to unless it redirects/forwards to another URL.. in this > > > >>>>>>> case, the > > > >>>>>>> server would append to the URL you requested, redirecting you... > > > >>>>>>> but > > > >>>>>>> even if > > > >>>>>>> it did this, your response would indicate a 3xx redirect and the > > > >>>>>>> Location > > > >>>>>>> header, as Frank says above, would contain the new URL you should > > > >>>>>>> go > > > >>>>>>> to. If > > > >>>>>>> you did get a 301/2 back, you'd have to actually make another > > > >>>>>>> request > > > >>>>>>> yourself. > > > > >>>> So not sure as the other guys say, what URL you are talking about > > > > >>>> On Tue, Apr 6, 2010 at 7:59 PM, Frank Weiss<[email protected]> > > > >>>>>>> wrote: > > > > >>>> I don't know what "response URL" means. The only URLs in an HTTP > > > >>>>>>>> response > > > >>>>>>>> that come to mind are: 1) the "Location" response header for a > > > >>>>>>>> 301/302 > > > >>>>>>>> status code, 2) some string in the response data (such as an HTML > > > >>>>>>>> anchor > > > >>>>>>>> element) that you want to interpret as a URL. > > > > >>>> On Tue, Apr 6, 2010 at 1:59 PM, jw<[email protected]> wrote: > > > > >>>> Hi all, > > > > >>>> I have a problem. I'm doing a http post request to a URL like this; > > > > >>>> DefaultHttpClient httpclient = new DefaultHttpClient(); > > > >>>>>>>>> HttpPost httppost = new HttpPost(url); > > > >>>>>>>>> HttpResponse response = httpclient.execute(httppost); > > > > >>>> I am able to get the response content (html in this case) but I would > > > >>>>>>>>> like to be able to get the url of the response. Is there a way? > > > >>>>>>>>> Or > > > >>>>>>>>> could i use some other technique to do the post request and > > > >>>>>>>>> retrieve > > > >>>>>>>>> the url? > > > > >>>> The repsonse url is > > > >>>> lkewww.url.com?x=1&y=2<http://www.url.com/?x=1&y=2>and > > > >>>>>>>>> would like to get the > > > >>>>>>>>> parameter values, I've tried to use the > > > >>>>>>>>> getParams().getParameter() > > > >>>>>>>>> on > > > >>>>>>>>> the HttpResponse object without any success. So if anyone has a > > > >>>>>>>>> solution to get the parameters without getting the url, that's > > > >>>>>>>>> ok > > > >>>>>>>>> :) > > > > >>>> Thanks in advance. > > > > >>>> /J > > > > >>>> -- > > > >>>>>>>>> You received this message because you are subscribed to the > > > >>>>>>>>> Google > > > >>>>>>>>> Groups "Android Developers" group. > > > >>>>>>>>> To post to this group, send email to > > > >>>>>>>>> [email protected] > > > >>>>>>>>> To unsubscribe from this group, send email to > > > >>>>>>>>> [email protected]<android-developers%2Bunsubs > > > >>>>>>>>> [email protected]> > > > >>>>>>>>> <android-developers%[email protected]<android-developers%252Bu > > > >>>>>>>>> [email protected]> > > > > >>>>>>>>> For more options, visit this group at > > > >>>>>>>>>http://groups.google.com/group/android-developers?hl=en > > > > >>>> To unsubscribe, reply using "remove me" as the subject. > > > > >>>> -- > > > >>>>>>>> You received this message because you are subscribed to the > > > >>>>>>>> Google > > > >>>>>>>> Groups "Android Developers" group. > > > >>>>>>>> To post to this group, send email to > > > >>>>>>>> [email protected] > > > >>>>>>>> To unsubscribe from this group, send email to > > > >>>>>>>> [email protected]<android-developers%2Bunsubs > > > >>>>>>>> [email protected]> > > > >>>>>>>> <android-developers%[email protected]<android-developers%252Bu > > > >>>>>>>> [email protected]> > > > > >>>>>>>> For more options, visit this group at > > > >>>>>>>>http://groups.google.com/group/android-developers?hl=en > > > > > -- > > > > You received this message because you are subscribed to the Google > > > > Groups "Android Developers" group. > > > > To post to this group, send email to [email protected] > > > > To unsubscribe from this group, send email to > > > > [email protected]<android-developers%2Bunsubs > > > > [email protected]> > > > > For more options, visit this group at > > > >http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

