/*
 *  Copyright 2015 Adobe Systems Incorporated
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package ${package}.core.servlets;

import org.apache.felix.scr.annotations.sling.SlingServlet;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;

import javax.servlet.ServletException;
import java.io.IOException;

/**
 * Servlet that writes some sample content into the response. It is mounted for
 * all resources of a specific Sling resource type. The
 * {@link SlingSafeMethodsServlet} shall be used for HTTP methods that are
 * idempotent. For write operations use the {@link SlingAllMethodsServlet}.
 */
@SuppressWarnings("serial")
@SlingServlet(resourceTypes = "${appsFolderName}/structure/page")
public class SimpleServlet extends SlingSafeMethodsServlet {

    @Override
    protected void doGet(final SlingHttpServletRequest req,
            final SlingHttpServletResponse resp) throws ServletException, IOException {
        final Resource resource = req.getResource();
        resp.getOutputStream().println(resource.toString());
        resp.getOutputStream().println(
                "This content is generated by the SimpleServlet");
    }
}

@@ -984,16 +984,63 @@
 Servlet;
+%0Aimport org.apache.sling.api.resource.ValueMap;
 %0A%0Aimport
@@ -1473,16 +1473,27 @@
 erName%7D/
+components/
 structur
@@ -1499,16 +1499,57 @@
 re/page%22
+,%0A    extensions = %22txt%22, methods = %22GET%22
 )%0Apublic
@@ -1604,16 +1604,70 @@
 vlet %7B%0A%0A
+    private static final long serialVersionUid = 1L;%0A%0A
     @Ove
@@ -1890,53 +1890,35 @@
 esp.
-getOutputStream().println(resource.toString()
+setContentType(%22text/plain%22
 );%0A 
@@ -1936,96 +1936,85 @@
 .get
-OutputStream().println(%0A                %22This content is generated by the SimpleServlet%22
+Writer().write(%22Title = %22 + resource.adaptTo(ValueMap.class).get(%22jcr:title%22)
 );%0A 

Rework SimpleServlet to bind to the page resource type