Apache Sling Scripting Java Support

Clone this repo:
  1. 05dc1aa SLING-12094 - Use GitHub for the Maven scm.url value by Robert Munteanu · 7 months ago master
  2. 70b64f5 SLING-11709 - Set up Jira autolinks to all Sling Github projects by Robert Munteanu · 1 year, 1 month ago
  3. 181277b SLING-11051 - Fixing JavaDoc badge by Dan Klco · 2 years, 3 months ago
  4. cbbec89 SLING-10676 - remove SECURITY.md which is not needed by Bertrand Delacretaz · 2 years, 9 months ago
  5. 10ebf59 SLING-10676 - add or update SECURITY.md by Bertrand Delacretaz · 2 years, 9 months ago

Apache Sling

Build Status Coverage Sonarcloud Status JavaDoc Maven Central Contrib scripting License

Apache Sling Scripting Java Support

This module is part of the Apache Sling project.

This module implements a script engine for java servlets, that are compiled on the fly by Sling.

To test it:

  1. Install this bundle in Sling, for example with

mvn -P autoInstallBundle clean install -Dsling.url=http://localhost:8080/system/console

If Sling is running with the launchpad/testing setup.

  1. Create /apps/foo/foo.java in your repository (via WebDAV for example), with this code:

package apps.foo;

import java.io.IOException; import javax.servlet.ServletException; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.servlets.SlingSafeMethodsServlet;

public class foo extends SlingSafeMethodsServlet {

protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) 
throws ServletException, IOException {
    response.setContentType("text/plain");
    response.getWriter().write("Response from " + getClass().getName() + " at " + new java.util.Date());
}

}

  1. Request http://localhost:8080/content/foo/*.html which should display something like

Response from apps.foo.foo at Tue Nov 18 14:49:14 CET 2008

  1. The servlet code should be automatically recompiled after any changes.