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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

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
heyhey_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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.