--- title: "Function Structure" url: https://docs.catalyst.zoho.com/en/smartbrowz/help/browser-logic/function-structure/ description: "Code a Catalyst Serverless function to perform any browser task that you would otherwise manually do." last_updated: 2025-10-09T16:11:25Z service: SmartBrowz type: general --- # Browser Logic Function Structure When you [create a Browser Logic function](https://docs.catalyst.zoho.com/en/smartbrowz/help/browser-logic/implementation/) from the Catalyst CLI, it is created with a boilerplate code structure as shown below. Catalyst also creates the required dependencies and configuration files for your function and your project. You can refer to the [Project Directory Structure](https://docs.catalyst.zoho.com/en/cli/v1/project-directory-structure/introduction/) help page for details about the general configuration files. ### Java > **Note:** This boilerplate code below will be present in your function file when you initialize a browser logic function in Java with Selenium ```java import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.json.simple.JSONObject; import org.openqa.selenium.chrome.ChromeDriver; import com.catalyst.browserlogic.SeleniumHandler; public class BrowserlessExample implements SeleniumHandler { private static final Logger LOGGER = Logger.getLogger(SeleniumExample.class.getName()); JSONObject responseData = new JSONObject(); @Override @SuppressWarnings("unchecked") public void runner(HttpServletRequest request, HttpServletResponse response,ChromeDriver driver) throws Exception { try { //Fetches the endpoint and method to which the call was made String url = request.getRequestURI(); String method = request.getMethod(); driver.get("https://www.example.com"); responseData.put("message", "Title of the page "+driver.getTitle()); //Sends the response back to the Client response.setContentType("application/json"); response.getWriter().write(responseData.toString()); response.setStatus(200); } catch (Exception e) { //The actions are logged. You can check the logs from Catalyst Logs. LOGGER.log(Level.SEVERE, "Exception in SeleniumExample", e); responseData.put("error", "Internal server error occurred. Please try again in some time."); response.getWriter().write(responseData.toString()); response.setStatus(500); } } } ``` ### NodeJS > **Note:** This boilerplate code below will be present in your function file when you initialize a browser logic function in NodeJS with Puppeteer ```java module.exports.puppeteer = async (request, response, page) => { await page.goto('https://example.com/',{waitUntil: "domcontentloaded"}); const pageTitle = await page.title(); response.setHeader('Content-Type', 'application/json'); response.write(JSON.stringify({ output: pageTitle })); response.end(); }; ```