0

Here is my problem :

I have to perform post from java code to some page , get the data and parse it. The problem is that only my country ip can post to this page. Requests from another ip's are rejected. I want to find workaround. I have added my html page on server in my country (this server accessible from all ips) . Now I am sending a get request (in open to all server) to this page from Java code. What I want to do is to redirect my html page to post to the original page.

I tried to use redirection , but it doesn't work - from Java code I get my html page and not redirected one.

Is there any solution or my problem ?

Thanks

Matvey
  • 163
  • 2
  • 10
  • Have you checked if these solve your problem? [How can I make a redirect page in jQuery/JavaScript?](http://stackoverflow.com/questions/503093/how-can-i-make-a-redirect-page-in-jquery-javascript?rq=1) [How to redirect from an HTML page?](http://stackoverflow.com/questions/5411538/how-to-redirect-from-an-html-page?rq=1) – David Jan 15 '14 at 12:44

2 Answers2

1

I tried to use redirection , but it doesn't work - from Java code I get my html page and not redirected one.

Yes it wont work because redirection works on client side. You perform a request to your HTML page which sends back a redirect header and your Java implementation doesnt know what to do with it. Even if it did, it had to make a new request to redirected page, which means that the request to the redirected page would still be from a denied IP.

Another option is that your redirection HTML uses JavaScript window.location.assign or something like that. The point remains the same, beacause this also is a client side solution.

You have to use some kind of server side language on the host where you placed your HTML and in that server side script you have to perform a (post or get as you wish) request to only-your-country URL. This way this only-your-country URL will see that the request came from the host where the script was, not the client itself.

For example if you can use java as your server side language on the place where currently your redirection html is, then you can check out this thread: How to send simple http post request with post parameters in java

Community
  • 1
  • 1
Tarmo
  • 3,851
  • 2
  • 24
  • 41
  • I don't have many experience in web programming, Which server side solution is best for me ? This is very simple server. It don't think it can run php or java code. How can I write java code and run it on server side ? – Matvey Jan 15 '14 at 13:52
  • The best server side solution is what your server allows you to do. If the server is your own machine then it can be whatever you feel comfortable with if you have hosting provider then you should check your options with that provider. – Tarmo Jan 15 '14 at 14:22
0

You need a reverse proxy installed on a server located in your country. If you make a request to this reverse proxy, it will make a request to the only-your-country server and when it gets a response it will forward it to you. So the only-your-country server will receive the same request as you make to the reverse proxy, but with a source IP address changed to the IP of the reverse proxy server.

Ján Halaša
  • 8,167
  • 1
  • 36
  • 36