0

I am using java.net to create a simple request with a URL. This url returns a unique result each time. When the app is on the dev server everything works fine. When deployed to GAE the same result is returned over and over again no matter how many times I call the url. If I copy and paste the actual URL into a browser it returns a new unique result each time the request is made thus working as intended. What is likely to be causing this issue? Any help would be greatly appreciated.

Chris Vaught
  • 117
  • 1
  • 8

2 Answers2

0

Try using the URLConnection class, let me know how it works out, the issue may be caching

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

public class Test {

    public static void main(String[] args) throws IOException {
        System.out.println(getData("http://www.google.com/"));
    }

    public static String getData(String path) throws IOException {
        URL url = new URL(path);
        URLConnection urlc = (URLConnection) url.openConnection();
        urlc.setUseCaches(false);
        urlc.connect();
        InputStream is = urlc.getInputStream();
        String s = "";
        int info;
        while ((info = is.read()) != -1) {
            s += (char) info;
        }
        is.close();
        return s;
    }
}
Logan Murphy
  • 6,120
  • 3
  • 24
  • 42
  • I actually have primarily been using HttpURLConnection all along. I have setUsesCaches(false) and it did not fix the issue. – Chris Vaught Aug 07 '13 at 17:53
0

Did you try to empty the cache in the browser to discard caching issues. also might be caching at the network level. Also Try other common timestamp params like ts,timestamp,etc. Maybe the service will accept one.

Zig Mandel
  • 19,571
  • 5
  • 26
  • 36
  • Thank you for the suggestion. I was able to add the parameter "_" to fix the issue and the service would ignore it. – Chris Vaught Aug 07 '13 at 22:28