org.apache.sling.servlets.compat.impl

## Class JsonQueryServlet

- java.lang.Object
- - javax.servlet.GenericServlet
  - - org.apache.sling.api.servlets.SlingSafeMethodsServlet
    - - org.apache.sling.servlets.compat.impl.JsonQueryServlet

All Implemented Interfaces:
  Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

    @Service(value=javax.servlet.Servlet.class)
    @Properties(value={@Property(name="service.description",value="Default Query Servlet"),@Property(name="service.vendor",value="The Apache Software Foundation"),@Property(name="sling.servlet.resourceTypes",value="sling/servlet/default"),@Property(name="sling.servlet.extensions",value="json"),@Property(name="sling.servlet.selectors",value="query"),@Property(name="sling.servlet.prefix",intValue=-1,propertyPrivate=true)})
    public class JsonQueryServlet
    extends org.apache.sling.api.servlets.SlingSafeMethodsServlet

A SlingSafeMethodsServlet that renders the search results as JSON data Use this as the default query servlet for json get requests for Sling

See Also:
  Serialized Form

### Field Summary

Fields
`static String` `EXCERPT_PATH` exerpt lookup path
`static String` `OFFSET` Result set offset
`static String` `PROPERTY` property to append to the result
`static String` `QUERY_TYPE` Query type
`static String` `ROWS` Number of rows requested
`static String` `STATEMENT` Search clause
`static String` `TIDY`

### Constructor Summary

Constructors
Constructor and Description
`JsonQueryServlet()`

### Method Summary

Methods
`protected void` `doGet(org.apache.sling.api.SlingHttpServletRequest req, org.apache.sling.api.SlingHttpServletResponse resp)`
`protected String` `getQueryType(org.apache.sling.api.SlingHttpServletRequest req)` Retrieve the query type from the request.
`protected String` `getStatement(org.apache.sling.api.SlingHttpServletRequest req, String queryType)` Retrieve the query statement from the request.
`protected boolean` `isTidy(org.apache.sling.api.SlingHttpServletRequest req)` True if our request wants the "tidy" pretty-printed format

### Methods inherited from class org.apache.sling.api.servlets.SlingSafeMethodsServlet

`doGeneric, doHead, doOptions, doTrace, getAllowedRequestMethods, getServletInfo, handleMethodNotImplemented, mayService, service, service`

### Methods inherited from class javax.servlet.GenericServlet

`destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, init, log, log`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### STATEMENT

    public static final String STATEMENT

Search clause

See Also:
  Constant Field Values

#### QUERY_TYPE

    public static final String QUERY_TYPE

Query type

See Also:
  Constant Field Values

#### OFFSET

    public static final String OFFSET

Result set offset

See Also:
  Constant Field Values

#### ROWS

    public static final String ROWS

Number of rows requested

See Also:
  Constant Field Values

#### PROPERTY

    public static final String PROPERTY

property to append to the result

See Also:
  Constant Field Values

#### EXCERPT_PATH

    public static final String EXCERPT_PATH

exerpt lookup path

See Also:
  Constant Field Values

#### TIDY

    public static final String TIDY

See Also:
  Constant Field Values

### Constructor Detail

#### JsonQueryServlet

    public JsonQueryServlet()

### Method Detail

#### isTidy

    protected boolean isTidy(org.apache.sling.api.SlingHttpServletRequest req)

True if our request wants the "tidy" pretty-printed format

#### doGet

    protected void doGet(org.apache.sling.api.SlingHttpServletRequest req,
             org.apache.sling.api.SlingHttpServletResponse resp)
                  throws IOException

Overrides:
  `doGet` in class `org.apache.sling.api.servlets.SlingSafeMethodsServlet`
Throws:
  `IOException`

#### getQueryType

    protected String getQueryType(org.apache.sling.api.SlingHttpServletRequest req)

Retrieve the query type from the request.

Parameters:
  `req` - request
Returns:
  the query type.

#### getStatement

    protected String getStatement(org.apache.sling.api.SlingHttpServletRequest req,
                      String queryType)

Retrieve the query statement from the request.

Parameters:
  `req` - request
  `queryType` - the query type, as previously determined
Returns:
  the query statement.