URL redirect

Hi

I am trying to code a servlet, which will redirect to a different site, without changing the URL displayed in the Browser.

Can any one please tell me how can I do it?
thanks
W122498Asked:
Who is Participating?
 
heyhey_Connect With a Mentor Commented:
check
http://www.cjb.net/

they have implemented
'URL cloaking. URL cloaking keeps your CJB.NET address in the address bar of your browser when your web site is accessed through its CJB.NET address. People bookmarking your site will bookmark your CJB.NET address, and search engines will index your site using your CJB.NET address. Keyword and description meta tags can also be used with the URL cloaking option.'
0
 
W122498Author Commented:
Adjusted points to 200
0
 
moses123Commented:
W --
the way to do this is to trick the browser to think his getting the URL he requested is by getting it yourself inside the servlet and sending the byte array to the requesting browser  ..
to do so you need to open a URLConnectionon your inside the servlet get the HTML from the remote site and ---> pipe it to the browser   GOOD LUCK .. :)
 
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
W122498Author Commented:
Hi Moses123,

but there is a catch if I do it like that.

The gif, references are not resolved! Why because the gif refer to local files on m/c where the original file resided, and are not available to the servlet!!!!!

cheers
W
0
 
W122498Author Commented:
Hi Moses123,

but there is a catch if I do it like that.

The gif, references are not resolved! Why because the gif refer to local files on m/c where the original file resided, and are not available to the servlet!!!!!

cheers
W
 

 
   
0
 
heyhey_Commented:
GIF files will be donwnloaded from the original place.
0
 
moses123Commented:
heyhey & w

It depends  if in the orignal HTML file the gif ref are in a format
of a full URL Address or in there reference to the source URL.

0
 
heyhey_Commented:
hmmm ... ok, you can still code the servlet using this idea. and this is the only possible solution that works without client code (other possible solutions are:
- you can probably change the location text with some client side JavaScript
- you can use Frames)
0
 
Ravindra76Commented:


Hi,

 you can use Frames.

 main.html

<html>
<head>
<frameset cols=20%,*>
<frame name=a src=a.html>
<frame name=b src=a1.html>
</frameset>
</head>
</html>

a.html

<html>
<body>
<a href=http://www.yahoo.com/ target=b>Yahoo
</a>
</body>
</html>

a1.html

<html>
<body>
Hello
</body>
</html>

Run the main.html and click on yahoo.

The URL won't chanage in the navigation bar

Apply same logic for servlets also.

BEst of luck
0
 
W122498Author Commented:
Hi Ravindra76

I don't want to use frames :-) as the purpose is defeated

cheers
0
 
heyhey_Commented:
what about 'some client side JavaScript' ? :)
0
 
W122498Author Commented:
Hi HeyHey

Is there any thing simpler

cheers
W
0
 
heyhey_Commented:
I don't think that there is anything simpler. after all, you are trying to CHEAT :)

at the moment you have three possible solutions:
1. read the original file from your servlet and send it to the browser
1.0. replacing all the <A HREF= >s
1.1. handling additional requests from the same servlet (relative URLs) - won't work all of the time
2. Frames
3. client side JavaScript that will replace the URL field.

you can check go.to and some other forwarders to see what technique they use.
0
All Courses

From novice to tech pro — start learning today.