Sling is a Web application framework based on REST principles that provides easy development of content-oriented applications.
Sling uses a JCR repository, such as Apache Jackrabbit, as its data store.
Sling started as an internal project of Day Management AG and has been contributed to the Apache Software Foundation and is currently undergoing incubation.
The main purpose of Sling is to develop a content-centric Web Application framework for Java Content Repository (JCR) based data stores.
Getting started with Sling
Pre-requisite
- A Subversion client to get the Sling code
- A Java 5 JDK
- Maven ( > V 2.0.7)
- cURL to create content
Setup & Install
Check out the code from Subversion repository:
http://svn.apache.org/repos/asf/incubator/sling/trunk sling
This creates a directory named sling under the current directory, with the completed Sling source code.
In the top-level sling directory that was created by the svn command, run:
mvn clean install
This builds and tests all the Sling modules that are required to run the Launchpad.
If you don’t want to test the modules and just build them then you can run:
mvn clean install -Dmaven.test.skip=true
Start the Launchpad
Change to the launchpad/webapp directory under the top-level sling directory, and run:
mvn jetty:run
When server starts successfully it shows a message like this:

By default, Jetty is configured to run on port 8888.
Look at http://localhost:8888/sling where Sling displays the Sling Management Console page.
Sling Management Console Page will look like this:
In case of any error / issue, look into logs at below URL.
../launchpad/webap/target/sling/logs/error.log
Create some content
To create a content node (nodes are a JCR concept, a unit of storage) with cURL, use:
curl -F"sling:resourceType=foo/bar" -F"title=some title" http://admin:admin@localhost:8888/content/mynode
- the entire command should be in single line
You can check the node at http://localhost:8888/content/mynode
It will show you a page like this:

You can see the node, content, resourcetype and other files at WebDAV client. Login with admin/admin.
WebDAV client URL: http://admin:admin@localhost:8888/dav/default/
It will show you a repository like this:

You can use cURL to create directories.
curl -X MKCOL http://admin:admin@localhost:8888/dav/default/apps
curl -X MKCOL http://admin:admin@localhost:8888/dav/default/apps/foo
curl -X MKCOL http://admin:admin@localhost:8888/dav/default/apps/foo/bar
Example 1:
I will create a resourceType.
I will create a content node.
I will render the content through resourceType.
Creating resourceType
Run below command
curl -X MKCOL http://admin:admin@localhost:8888/dav/default/apps/example1
curl -X MKCOL http://admin:admin@localhost:8888/dav/default/apps/example1/examplepage1
It will create a resourceType of example1/examplepage1
Create a HTML script which will use JCR data
html.esp
<html>
<body>
<h1><%= currentNode.title %></h1>
<h2>This is testing for Sling:Resources</h2>
</body>
</html>
Upload it to example1/examplepage1 resourceType
curl -X PUT -d @html.esp http://admin:admin@localhost:8888/dav/default/apps/example1/examplepage1/html.esp
Create content based on resourceType example1/examplepage1
curl -F"sling:resourceType=example1/examplepage1" -F"title=Example Title" http://admin:admin@localhost:8888/content/examplecontent
Render the content
You will see the content like this:

If you want to include some other esp in your html.esp file then you can include in like this:
<html>
<body>
<div id="header">
<% sling.include("/content/header"); %>
</div>
<h1><%= currentNode.title %></h1>
</body>
</html>
- header.esp is a different esp file
We still do not have any complete solution / example but there are some sample scripts and servlets in the sling/sample module in the source tree. Going forward we may use them to do some more R&D on this.
Below are few URLs which might be useful if you are looking for more information.
Detailed project status:
http://incubator.apache.org/projects/sling.html
Detailed information on REST:
http://en.wikipedia.org/wiki/Representational_State_Transfer
Detailed project information:
http://incubator.apache.org/sling/site/project-information.html
Documentation on Sling:
http://incubator.apache.org/sling/site/documentation.html