Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: How to replace the default json renderer - thanks Felix for the script trick

...

Table of Contents
minLevel3

Scripts and Servlets

How to replace the default json renderer (for example) with my own?

The JSON rendering is done by the DefaultGetServlet, which is hardwired to use the JsonRendererServlet for .json extensions.

If a servlet or script is registered for the sling/servlet/default resource type, but with a specific sling.servlet.extensions property (set using the @scr.property annotation), it will take over and process GET requests which have a .json extension and no specific servlet or script.

As scripts and servlets are equivalent in Sling, the simplest way to do this to create a script at apps/sling/servlet/default/json.esp, for example.

The same logic applies to other extensions (html, txt, ...) handled by the DefaultGetServlet.

Working with bundles

Is there an easy way to update bundles in a running installation during development?

...