tree: b7b9dfad7f0a4111d63b501b0920aaffbac45a00 [path history] [tgz]
  1. src/
  2. pom.xml
  3. README.md
javashell/README.md

Apache Sling Javashell sample

This module is part of the Apache Sling project.


SECURITY WARNING: javashell lets user execute arbitrary code with NO LIMITS, and is only meant as a teaching/demo tool. Use at your own risk, or do not use if you don't understand the issues.

Just try “System.exit(0)” if you don't know what this means ;-)

This sample application executes java code entered in an HTML form, by generating and compiling java servlets on the fly.

Launch Sling

The Sling Container can be launched by running the following command in the launchpad/builder/target directory: java -jar org.apache.sling.launchpad--standalone.jar so if the current version is 7, the command should be: java -jar org.apache.sling.launchpad-7-standalone.jar

Prerequisites

To run this demo the following bundle must be installed: org.apache.sling.scripting.java

Install it as follows: contrib/scripting/java $ mvn install -P autoInstallBundle

Run this sample

Build and install the sample bundle by running $ mvn install -P autoInstallBundle

Then:

  1. Log in by navigating to: http://localhost:8080/system/sling/login.html using admin/admin as credentials.

  2. Navigate to: http://localhost:8080/content/javashell/scripts/first_example.html

    That page should include a “Result of execution” section which lists some properties and child nodes. This section is generated by the javashell script.

    If you get the default HTML rendering under the “Result of execution” header, the scripting.java bundle is probably not active.

  3. The above page includes links to edit the java code, and create new pages with more code to execute.

The servlets are generated under /apps/javashell/servlets, and are not cleaned up currently, this is something that should be improved.