views:

51

answers:

2

Hi people,

i need to write a program, that can redirect's http://localhost:8080 to en.wikipedia.org, it seems to be easy, but i have some problems(only with wikipedia with another sites works good). I make url to wikipedia:

URL url = new URL("http", "en.wikipedia.org", 80, "/wiki");

than URLConnection, extract headers, and when i want connection.getInputStream(), i received message 404 Not Found. So i have tried some hack for host header, because in this way host header is localhost:8080, therefor i have tried to change host header to wikipedia, and it works, but after request in browser http://localhost:8080 wikipedia opens, but url in browser changes to en.wikipedia.org, but i want proceed with localhost :)

A: 

Would this be the method you are looking for?

http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletResponse.html#sendRedirect%28java.lang.String%29

seanizer
My understanding is that Le_Coeur wants not to redirect, but to proxy wikipedia: "but i want proceed with localhost".
Christian Semrau
Then Apache httpclient might be a better solution: http://hc.apache.org/httpclient-3.x/
seanizer
Yes, i want something like proxy(direct proxy) Example:page http://en.wikipedia.org/wiki/Apple must be under http://localhost:8080/wiki/Apple
Le_Coeur
to the funny comedian who downvoted me: I answered the question. it's not my fault that the wrong question was asked...
seanizer
A: 

Wikipedia uses Javascript to escape frames in foreign websites. Basically, the Javascript compares the browser URL with the wikipedia URL and reloads the real wikipedia URL if it differs. So probably this affects you, too.

Try disabling Javascript in your browser.

Christian Semrau