开发者

Redirected wikipedia request

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 URLConnectio开发者_JAVA百科n, 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 :)


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜