{"id":33190378,"url":"https://github.com/metamug/mason","last_synced_at":"2026-01-14T02:57:56.949Z","repository":{"id":34601956,"uuid":"137570202","full_name":"metamug/mason","owner":"metamug","description":"REST APIs with JSP tags, SQL and much more.","archived":false,"fork":false,"pushed_at":"2023-04-14T17:49:42.000Z","size":31051,"stargazers_count":27,"open_issues_count":68,"forks_count":11,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-11-21T00:05:24.997Z","etag":null,"topics":["jdbc","jsp","jstl","rest-api","sql"],"latest_commit_sha":null,"homepage":"https://metamug.github.io/mason","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/metamug.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":"https://paypal.me/metamug"}},"created_at":"2018-06-16T09:47:03.000Z","updated_at":"2025-06-20T08:11:03.000Z","dependencies_parsed_at":"2024-01-15T20:06:11.584Z","dependency_job_id":null,"html_url":"https://github.com/metamug/mason","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/metamug/mason","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metamug%2Fmason","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metamug%2Fmason/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metamug%2Fmason/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metamug%2Fmason/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metamug","download_url":"https://codeload.github.com/metamug/mason/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metamug%2Fmason/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jdbc","jsp","jstl","rest-api","sql"],"created_at":"2025-11-16T06:00:34.444Z","updated_at":"2026-01-14T02:57:56.926Z","avatar_url":"https://github.com/metamug.png","language":"Java","readme":"# 🧱 MASON \r\n![Build Status](https://github.com/metamug/mason/actions/workflows/main.yml/badge.svg) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.metamug/mason/badge.svg)](http://search.maven.org/#artifactdetails|com.metamug|mason|4.8) [![javadoc.io](https://javadoc.io/badge2/com.metamug/mason/javadoc.io.svg)](https://javadoc.io/doc/com.metamug/mason)  [![Coverage Status](https://coveralls.io/repos/github/metamug/mason/badge.svg?branch=develop)](https://coveralls.io/github/metamug/mason?branch=develop) [![LGPL v2.1 License](https://img.shields.io/badge/License-LGPL%20v2.1-blue.svg)](https://opensource.org/licenses/LGPL-2.1) [![Gitter](https://badges.gitter.im/metamug-mason/community.svg)](https://gitter.im/metamug-mason/community?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\r\n\r\n\r\n\r\nMason is an open-source, lightweight data access layer for REST resources designed to be used in Java web applications. It handles incoming API requests and routes the parameters to these resources.\r\n\r\n```xml\r\n\u003cdependency\u003e\r\n  \u003cgroupId\u003ecom.metamug\u003c/groupId\u003e\r\n  \u003cartifactId\u003emason\u003c/artifactId\u003e\r\n  \u003cversion\u003e4.8\u003c/version\u003e\r\n\u003c/dependency\u003e\r\n```\r\n\r\n### Motivation\r\n\r\nUse JSP tags for editing database queries and request handling. To hot deploy REST APIs without compiling/deploying Java classes. Build REST APIs with JSP tags.\r\n\r\n```xml\r\n\u003cjsp:directive.include file=\"../fragments/mason-init.jspf\"/\u003e\r\n\u003c%-- customer.jsp --%\u003e\r\n\u003cm:resource\u003e\r\n    \u003cm:request method=\"GET\"\u003e\r\n     \t\u003csql:query var=\"customers\" dataSource=\"${datasource}\"\u003e \r\n\t\tSELECT name, address, phone, type from retail_customer \r\n    \t\u003c/sql:query\u003e\r\n     \t\u003cc:set target=\"${output}\" property=\"customers\" value=\"${customers}\"/\u003e\r\n    \u003c/m:request\u003e\r\n\u003c/m:resource\u003e\r\n```\r\n\r\nSample Project\r\n- https://github.com/metamug/mason-sample\r\n\r\n### Mason Resources\r\n\r\nMason turns your Plain Old JSPs (with neat tag libraries) into REST Resources. Mason doesn't encourage [using scriptlets in Resource JSPs](http://balusc.omnifaces.org/2010/07/how-to-avoid-java-code-in-jsp-files.html).\r\n\r\nYou can handle GET, POST, PUT, DELETE requests in your JSP. Mason has been tested with tomcat 9. *jstl.jar* shipped with tomcat is make jstl work.\r\n\r\nLearn more about jsp configurations here.\r\nhttps://tomcat.apache.org/tomcat-9.0-doc/jasper-howto.html\r\n\r\n### Mason Query\r\n\r\nYou can write database queries inside the resource JSP files as seen in the above example or you can place them in `{webAppDir}/WEB-INF/classes/query.properties` file and reference them inside the JSP files for reuse.\r\n\r\n### Features?\r\n\r\n- Request Processing\r\n- Mapping resource URI to JSP\r\n- HTTP BASIC and JWT Authentication\r\n- Convert SQL Results into JSON/XML based on `Accept` Header 🌟\r\n- Make \u003ca href=\"https://metamug.com/docs/xrequest\" target=\"_blank\"\u003eExternal API Requests\u003c/a\u003e\r\n- \u003ca href=\"https://metamug.com/docs/request-parameters#pagination-parameters\" target=\"_blank\"\u003ePagination\u003c/a\u003e\r\n- Many more\r\n\r\n### Mason Jar\r\n\r\nClone and package the project with \u003ca href=\"https://maven.apache.org/download.cgi\" target=\"_blank\"\u003emvn\u003c/a\u003e\r\n\r\n```\r\nmvn clean package\r\n```\r\nAfter that you can find *mtg-mason-1.0.jar* inside the target folder. You can use this jar as a dependency in your Java webapp.\r\n\r\n### How to use mason in your Webapp\r\n\r\n1. Place the mason jar file in `{webAppDir}/WEB-INF/lib`\r\n\r\n2. Download [jstl](http://www.java2s.com/Code/Jar/j/Downloadjstl12jar.htm) jar file and place it inside `{webAppDir}/WEB-INF/lib`\r\n\r\n3. Create a folder `{webAppDir}/WEB-INF/resources/{resourceVersion}` and place your jsp files here. For example, `mywebapp/WEB-INF/resources/v1.0/foo.jsp`.\r\n4. Import mtg-mason.tld inside your jsp file. This taglib is present inside the mason jar and enables usage of the *mtg* prefix. You will also need to import the jstl taglib. Your jsp file should contain the following\r\n\r\n```xml\r\n\u003c% @taglib uri=\"http://java.sun.com/jsp/jstl/core\" prefix=\"c\" %\u003e\r\n\u003c% @taglib uri=\"http://java.sun.com/jsp/jstl/sql\" prefix=\"sql\" %\u003e\r\n\u003c% @taglib uri=\"mtg-mason.tld\" prefix=\"m\" %\u003e\r\n\u003c%@ page trimDirectiveWhitespaces=\"true\" %\u003e\r\n```\r\n\r\n5. Add the following filter and listener inside `{webAppDir}/WEB-INF/web.xml`\r\n\r\n```xml\r\n\u003cfilter\u003e\r\n    \u003cfilter-name\u003eRouter\u003c/filter-name\u003e\r\n    \u003cfilter-class\u003ecom.metamug.mason.Router\u003c/filter-class\u003e\r\n\u003c/filter\u003e\r\n\r\n\u003cfilter-mapping\u003e\r\n    \u003cfilter-name\u003eRouter\u003c/filter-name\u003e\r\n    \u003curl-pattern\u003e/*\u003c/url-pattern\u003e\r\n    \u003cinit-param\u003e\r\n        \u003cparam-name\u003edatasource\u003c/param-name\u003e\r\n        \u003cparam-value\u003ejdbc/mason\u003c/param-value\u003e\r\n    \u003c/init-param\u003e\r\n\u003c/filter-mapping\u003e\r\n```\r\n\r\nAll requests made to the jsp resources are routed through this filter.\r\n\r\n6.Configure your data source in [`{webAppDir}/META-INF/context.xml`](server/src/main/webapp/META-INF) file.\r\n\r\nYou can take a look at the [sample webapp](https://github.com/metamug/mason-sample).\r\n\r\n### JDBC Drivers\r\n\r\nExcept for javaee-web-api since that would be present in your application server and any one out of HSQL, MySQL or PostgreSQL dependency.\r\nWe also support Oracle database but due to its licensing we can't ship oracle jdbc driver along.\r\nSo in case you are using Oracle database, you'll have to manually install its driver as a dependency in your project.\r\n\r\nInstructions regarding how to do the same in below link(s) (You can refer either of them).\r\nhttps://www.mkyong.com/maven/how-to-add-oracle-jdbc-driver-in-your-maven-local-repository/\r\n\t\t\t\t\tOR\r\nhttps://stackoverflow.com/a/1074971/4800126\r\n\r\n### Data Format Support\r\n\r\nMason supports `application/xml`, `applicaton/json` and `application/json+dataset`\r\nRead More about how it is used here.\r\nhttps://metamug.com/docs/api-request\r\n\r\n### Scripting Support\r\n\r\nMason supports [groovy](http://groovy-lang.org/) for writing scripts. \r\nYou need to keep the scripts in [`{webAppDir}/WEB-INF/scripts`](server/src/main/webapp/WEB-INF/scripts)\r\n\r\n**Example Script**\r\n\r\n```groovy\r\n//test.groovy\r\ndef params = _request.getParams()\r\nres['message'] = 'Hello ' + params['name']\r\n```\r\nThe script can be invoked using `script` tag in jsp resource.\r\n```xml\r\n\u003cm:script file=\"test.groovy\" var=\"res\" /\u003e\r\n```\r\n\r\n### How To Contribute\r\n\r\nFork this repo and submit a PR against the listed issues. Any donations for this project will be paid to individual developers working in their personal capacity on this project. To reward them for their contribution and keeping Mason a community project.\r\n\r\n[![SonarCloud Bugs](https://sonarcloud.io/api/project_badges/measure?project=metamug_mason\u0026metric=bugs)](https://sonarcloud.io/component_measures/metric/reliability_rating/list?id=metamug_mason)\r\n [![SonarCloud Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=metamug_mason\u0026metric=vulnerabilities)](https://sonarcloud.io/component_measures/metric/security_rating/list?id=metamug_mason) [![Total alerts](https://img.shields.io/lgtm/alerts/g/metamug/mason.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/metamug/mason/alerts/) [![Language grade: Java](https://img.shields.io/lgtm/grade/java/g/metamug/mason.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/metamug/mason/context:java) \r\n \r\n","funding_links":["https://paypal.me/metamug"],"categories":["API Frameworks"],"sub_categories":["Java"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetamug%2Fmason","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetamug%2Fmason","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetamug%2Fmason/lists"}