Serving a website based on source internet address

S

Skybuck

Hello,

Based on the source internet address a different version of the website

should be presented/served to the user/browser.

For example in pseudo code:

if SourceAddress = '143.3.5.1' then
begin
ShowBlueWebsite; // Load/Show BlueIndex.htm
end else
if SourceAddress = '124.5.15.7' then
begin
ShowRedWebsite; // LoadShow RedIndex.htm
end;

Is this possible with java ? is there any source code available to do
this trick ?

Bye,
Skybuck.
 
B

Babu Kalakrishnan

Skybuck said:
Hello,

Based on the source internet address a different version of the website

should be presented/served to the user/browser.

For example in pseudo code:

if SourceAddress = '143.3.5.1' then
begin
ShowBlueWebsite; // Load/Show BlueIndex.htm
end else
if SourceAddress = '124.5.15.7' then
begin
ShowRedWebsite; // LoadShow RedIndex.htm
end;

Is this possible with java ? is there any source code available to do
this trick ?

Try the request.getRemoteHost() and/or the request.getRemoteAddr()
methods and send an appropriate redirect to the client based on the
values returned.

Make sure you test the application with whatever target servlet
engine(s) that ou plan to deploy your application on, as well as
different browsers / with and without proxies. In my experience, the
outputs returned by some of the methods of HttpServletRequest give you
surprises with certain combinations of UserAgent/Proxy/Servlet engine.

BK
 
T

Tom Cole

1. This was cross-posted in comp.lang.javascript where an answer was
posted.

2. When you say "done in java" I assume that you have a website that is
written in JSP/J2EE? From your other post it did not seem so...If so
then you don't even need to do this, you can setup hosts in your
servlet container which will handle this for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,048
Members
47,651
Latest member
VeraPiw932

Latest Threads

Top