Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

APIs to connect to Dispatcher and Extract information

Avatar

Level 2

Hi All,

Are there any APIs to connect to dispatchers and get cached files pro-grammatically.We want to get basically json files and process them.

Please help  me if anyone is already done the similar kind of implementations and share your experience.

Thanks,

GK

1 Accepted Solution

Avatar

Correct answer by
Level 10

Dispatcher is just a proxy. Use any http client or url connection to connect to webserver and get data.

http://docs.oracle.com/javase/tutorial/networking/urls/readingWriting.html

import java.net.*;
import java.io.*;

public class URLConnectionReader {
    public static void main(String[] args) throws Exception {
        URL oracle = new URL("http://localhost:4503/content/geometrixx-outdoors/en.json");
        URLConnection yc = oracle.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null)
            System.out.println(inputLine);
        in.close();
    }
}

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Dispatcher is just a proxy. Use any http client or url connection to connect to webserver and get data.

http://docs.oracle.com/javase/tutorial/networking/urls/readingWriting.html

import java.net.*;
import java.io.*;

public class URLConnectionReader {
    public static void main(String[] args) throws Exception {
        URL oracle = new URL("http://localhost:4503/content/geometrixx-outdoors/en.json");
        URLConnection yc = oracle.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null)
            System.out.println(inputLine);
        in.close();
    }
}