What I am trying to do :
1. I have created a small application (servlet, HTML & log4j.properties) that is deployed in a web server. There is a switch (say wireless router) that intercepts clients (who are outside network) trying to access wireless network and routes the request to the HTML in the application. The HTML contains some form info that user needs to fill and submit. When he submits this form, it sends the request to the servlet (via GET), the servlet logs the required info, authenticates user and needs to redirect the user back to the site that he initially tried to access.
2. I got everything working but the redirect part. What I am trying to do for redirection is this -
So, when the client tries to go to "www.google.com", the switch redirects to the HTML, user enters the form data and submits the page. This is then sent to the servlet which logs required info, but is not able to redirect to the site 'www.google.com'. The URL at the client end is changed to http://184.108.40.206/www.google.com (where 220.127.116.11 is the IP address of the web server that hosts this application.)
Seeking experts help in redirecting to an URL (which is outside the application) from servlet.
By "Complete URLs", did you mean I need to use "http://www.google.com" - instead of "www.google.com"? If so, I was just curious as to how to form the "Complete URL", because client can try any combination - like "google.com" or "www.google.com" or "http://www.google.com" or some other site that may not even have 'www' in the host name.
Just to remind, I am using GET method to retrieve the "redirectToClientUrl" variable from the html.
Bhaskar Reddy wrote:By "Complete URLs", did you mean I need to use "http://www.google.com" - instead of "www.google.com"?
If you provide a partial URL (e.g. one without the http:// protocol in front) then the server will expand it to a complete URL. You have already seen one possible result of that process and you naturally don't like what it does. So therefore it's up to you to do it the way you want it done.
Joined: Dec 17, 2002
Thank you for your insight!
Well, coming to think of what I am getting after the redirect -
what I want to do is to redirect the client URL to <<actual_client_url>>. (I am guessing the 'http://' will not be needed as the URL will be submitted by the browser to look up up for the DNS entry.) Is it possible to do so?
You are welcome. These things are often quite simple, but people tend to make them complicated by imagining they work in a way that those people want them to work as opposed to the way they actually work.
Bhaskar Reddy wrote:what I want to do is to redirect the client URL to <<actual_client_url>>. (I am guessing the 'http://' will not be needed as the URL will be submitted by the browser to look up up for the DNS entry.) Is it possible to do so?
If you provide a relative URL, then the server will assume it's a URL in its own domain. You have already done the experiments which show that to be the case. Believe what you are seeing. If you provide an absolute URL (complete with http://) then the server will take it as given. You have already tested this case.
Your requirements apparently allow the user to enter part of a URL, and require some guesswork to make it into a complete URL. Your experiments have shown that your server won't do this guesswork for you. So therefore you have to do it. This isn't difficult to see once you stop assuming that things work the way you want them to work. Just look at the way they actually work -- you've already done this -- and go from there.