?
Solved

Redirecting client browser to another server

Posted on 2003-03-03
10
Medium Priority
?
220 Views
Last Modified: 2010-03-31
Hello All!!

I have a scenario... When a client browser requests for a web page from my System, I must redirect the request to another Webserver running on a second PC.

For this I first coded a program that can get the client browser's header. I then sent this header to the Webserver running on the Second system. I then got the response(Webserver's HEader) from the second system and then I send it to the client's browser. After this process the webserver will actually start sending the files in 1K bytes. I am now having a problem in sending these bytes to the client system...

Any new ideas or ideas to implement will be much appriciated

Thank You

Shiva
0
Comment
Question by:shivasrini
9 Comments
 
LVL 92

Accepted Solution

by:
objects earned 272 total points
ID: 8062391
What don't you simply send a redirect?
0
 
LVL 2

Assisted Solution

by:functionpointer
functionpointer earned 264 total points
ID: 8062398
do you mean you are trying to proxy a chunked response? If so, you will have to either buffer it ( difficult ), or read the whole resonse from the server, put together and send it to the client in one piece.
0
 
LVL 4

Expert Comment

by:antons061400
ID: 8062544
If the client can access the second server directly you can return page like:

<HTML>
<HEAD>
<META HTTP-EQUIV="Refresh" CONTENT="1;URL=http://secondserver/.html">
</HEAD>
<BODY>
The page will be redirected in  one second.
</BODY>
</HTML>
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.

 
LVL 92

Expert Comment

by:objects
ID: 8062584
I already suggested sending a redirect.
0
 

Author Comment

by:shivasrini
ID: 8063506
Thanks for your response..

Actually it is not the problem of transfering web pages. Actually this is a netowrking project, where by I need to redirect the client that is accessing, to the second sever.

Finally the client must not know where his webpage is coming from.

Thanks
Shiva
0
 
LVL 1

Assisted Solution

by:tutran
tutran earned 264 total points
ID: 8066214
I guess what you're trying to do is to have webserver1 act like a broker, relaying message from webserver2 to the client without them knowing.

To simulate client's request header you want to get headers from request object, simulate user's request by setting headers connection properties using these headers.  Make sure that you have the standard header such as User-Agent, Content-Type, etc.  Let me know if further question:

conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

conn.setRequestProperty("User-Agent","Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0");

conn.setRequestProperty("Content-length", "" + text.length);      


Enumeration headers = req.getHeaderNames();
while (headers.hasMoreElements()) {
        String aHeaderName = (String) headers.nextElement();
        String aHeaderValue = (String) req.getHeader(aHeaderName);

        conn.setRequestProperty(aHeaderName, aHeaderValue);
}
0
 
LVL 2

Expert Comment

by:functionpointer
ID: 8069316
I assumed from your original question that you were receiving the data from the webserver in chunks, and that's what was giving you the problem proxying the response. Is this the case?
0
 

Expert Comment

by:CleanupPing
ID: 9058949
shivasrini:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9762116
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Split between objects, functionpointer and tutran

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TimYates
EE Cleanup Volunteer
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month7 days, 2 hours left to enroll

593 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question