In Service classes:
· ApplicationHolder.application.metadata.'relative.dir' --> returns "relative.dir" property value from application.properties
· ApplicationHolder.application.getMainContext().getResource('/').getFile().getAbsolutePath() --> returns the local root directory of the webapp on the server
· [inject] LinkGenerator grailsLinkGenerator (literally)
o grailsLinkGenerator.serverBaseURL + "/path" --> http://localhost:9999/context/path
o grailsLinkGenerator.link(uri: "/path", absolute: true) --> same as above (see javadoc on link())
In gsp:
· grailsApplication.metadata.'relative.reports.dir' --> returns "relative.dir: property value from application.properties
· request.getSession().getServletContext().getRealPath("/") --> returns the local root directory of the webapp on the server
· request.getSession().getServletContext().getRealPath("/path") --> returns /path relative to the local root directory of the webapp on the server
Snippets and thoughts from a passionate software developer interested in all things DevOps, Continuous Delivery, Functional Programming, Distributed Systems. Also on Twitter as @mcallana.