API / Apache Grails Interview questions
What is the difference between a Grails controller and a Grails service?
Both are Groovy classes managed by Grails' conventions, but they sit at different layers of the application and are responsible for fundamentally different concerns.
| Controller | Service |
| Location: grails-app/controllers | Location: grails-app/services |
| Handles HTTP requests, params binding, rendering views/JSON | Holds business logic, coordinates persistence and external calls |
| Not transactional by default | Transactional by default for every public method |
| URL-addressable, reached directly by a browser or API client | Not URL-addressable; called internally by controllers or other services |
The intended flow is that a controller receives a request, delegates the real work to one or more services, and then renders whatever result the service returns — keeping the controller's own logic limited to request/response concerns and letting the service layer hold logic that's easy to test and reuse independent of any particular HTTP endpoint.
More Related questions...