#1: One way to do this quite simply would be to use frames.

The browser will only show the location of the outermost frame (which would be your URL), but would not show the location of any pages in inner frames. Of course, if an enterprising user wanted to look at the URL of anything in an inner frame, all they really have to do is to right click on the frame and look at the info.

#2: The second way would be to actually have your servlet act as a gateway. You should write your servlet so that invoking it like
    http://my-domain/redirectServlet?url=http://some-url.com/some_page.html
would result in the servlet making a connection to the server at some-url.com and getting the requested page.

To keep up the deception, you would also have to pre-process any incoming pages to rewrite any HREFs so that they point to your gateway servlet with the HREF as a parameter. i.e. if the some_page.html has an HREF to some_other_page.html, you would have to rewrite that as
    http://my-domain/redirectServlet?url=http://some-url.com/some_other_page.html
before sending it to the browser.

Of course, all this will put unnecessary load on your server.

But, the fundamental question is why do you want to do this? If it is simply an image thing (you want it to look like you are providing the information), then method #1 is far far more simpler. If it is a control thing (like you want to restrict access to certain pages, or log people's web usage), maybe you can implement something similar with a proxy server rather than a servlet.

-- V

Hai-Bang Pham wrote:

Hello,

I was wondering if there is a way to hide the URL when trying to do
a HTTP redirect.  I've experimented with the response.sendRedirect()
method but the redirected URL is always shown.

This occurs if the redirect was to an HTML file i.e.
response.sendRedirect("http://server:port/index.html") or if the
redirect was to a servlet i.e.
response.sendRedirect("HelloWorldServlet")

What I basically want to accomplish with this is to develop a
"portal" servlet where all client requests will be handled.
In this situation, only one URL will be shown in the client
browser (on the browser address bar and for all form submit actions).

-Hai
 

Reply via email to