is it possible to clear the rest cache programmatically in 9.3.1?

1001
3
07-19-2011 06:12 AM
PrashantKhanal
New Contributor
The arcgis server 10 has an option where you can generate the admin cache token and use the token to clear the rest cache.

Is there any way we can clear the rest cache programmatically in 9.3.1?
0 Kudos
3 Replies
Ranga_Tolapi
Occasional Contributor III
0 Kudos
Ranga_Tolapi
Occasional Contributor III
This java code works...

import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

private static void clearRestCache(String server, String username, String password) {
        DefaultHttpClient httpclient = new DefaultHttpClient();
        try {
         String loginUrl = "http://" + server + ":8399/arcgis/rest/admin/login";
         String cacheClearUrl = "http://" + server + ":8399/arcgis/rest/admin/cache/clear";
            HttpGet httpget = new HttpGet(loginUrl + "?username=" + username + "&password=" + password + "&redirect=" + cacheClearUrl);
            httpclient.execute(httpget);
        } catch (Exception e) {
         e.printStackTrace();
        } finally {
            httpclient.getConnectionManager().shutdown();
        }
}
0 Kudos
RussellChiles
New Contributor II
Where would you run this script?
0 Kudos