--- title: "Configure the Advanced I/O function" url: https://docs.catalyst.zoho.com/en/tutorials/newsapp/java/configure-advancedio/ description: "Build a web news application that automatically fetches news from a third-party service periodically using the Catalyst Job Scheduling Cron component, and a Job Function and Advanced I/O function coded in Java." last_updated: 2025-11-19T15:07:41Z service: All Services type: tutorial related_links: - name: "Advanced I/O Function" url: /en/serverless/help/functions/advanced-io - name: "Data Store" url: /en/cloud-scale/help/data-store/introduction - name: "ZCQL" url: /en/cloud-scale/help/zcql/introduction --- # Configure the Advanced I/O Function The Advanced I/O function directory (`functions/NewsApp_AIO`) contains the following files: * The `DataStoreFetch.java` main function file * The `catalyst-config.json` configuration file * Java library files in the `lib` folder * `.classpath` and `.project` dependency files You will be adding code in the `DatastoreFetch.java` file. The Advanced I/O function fetches the news item from its source table in the Data Store and forwards it to the client component as a JSON response. Copy the code and paste it in the `DatastoreFetch.java ` in the `functions/NewsApp_AIO ` directory. **DatastoreFetch.java** ```java import java.util.logging.Logger; import java.util.ArrayList; import java.util.logging.Level; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.catalyst.advanced.CatalystAdvancedIOHandler; import com.zc.component.object.ZCRowObject; import com.zc.component.zcql.ZCQL; import org.json.JSONArray; import org.json.JSONObject; public class DatastoreFetch implements CatalystAdvancedIOHandler { private static final Logger LOGGER = Logger.getLogger(DatastoreFetch.class.getName()); @Override public void runner(HttpServletRequest request, HttpServletResponse response) throws Exception { try { // Fetch the endpoint and HTTP method String url = request.getRequestURI(); String method = request.getMethod(); if (url.equals("/fetchData") && method.equals("GET")) { String tableName = request.getParameter("tablename"); // Query the Data Store using ZCQL String query = "select title, url from " + tableName; ArrayList<ZCRowObject> rowList = ZCQL.getInstance().executeQuery(query); JSONObject data = new JSONObject(); JSONArray content = new JSONArray(); // Construct JSON response for (int i = 0; i < rowList.size(); i++) { JSONObject rowData = new JSONObject(); JSONObject tableData = new JSONObject(); ZCRowObject row = rowList.get(i); String title = (String) row.get("title"); String urlVal = (String) row.get("url"); rowData.put("title", title); rowData.put("url", urlVal); tableData.put(tableName, rowData); content.put(tableData); } data.put("content", content); // Send response back to client response.setContentType("application/json"); response.getWriter().write(data.toString()); response.setStatus(200); } else { // Invalid request LOGGER.log(Level.SEVERE, "Error. Invalid Request"); response.setStatus(404); } } catch (Exception e) { LOGGER.log(Level.SEVERE, "Exception in DatastoreFetch", e); response.setStatus(500); } } } ``` The Advanced I/O function is now configured. We will discuss the application's architecture after we configure the client.