|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.apache.velocity.tools.view.servlet.VelocityViewServlet
it.unimi.dsi.mg4j.query.QueryServlet
public class QueryServlet
A query servlet.
This class provides a basic servlet for searching a collection.
It expects some data (a collection, an index map and a path)
in the ServletContext
(see the code for init()
). It
can be used to search in a collection, but it is essentially a worked-out example.
The three parameters are q, the query, m, the maximum number of results to be displayed, and s, the first result to be displayed.
Usually, the URI associated to each result is taken from the collection. Alternatively, each
result will point to the /Item path with some query arguments (doc, containing
the document pointer, uri, containing the original URI, and m, containing
an optional suggested MIME type). See, for instance, GenericItem
and InputStreamItem
.
The Velocity template used by this servlet can be set using the initialisation parameter
template (or using a context attribute with the same name). If you're using
this servlet via HttpQueryServer
, please read the documentation therein for
information about template resolution order.
This servlet is thread safe. Each instance uses its own flyweight copies of the collection and query engine to return the result (in particular, snippets). In a production site it might be more sensible to pool and reuse such classes.
Field Summary | |
---|---|
protected static String |
DEFAULT_TEMPLATE
The default Velocity template used by this servlet; may be overriden in the context using an attribute named template. |
protected DocumentCollection |
documentCollection
The document collection. |
protected Object2ReferenceMap<String,Index> |
indexMap
A sorted map from index names to indices: the first entry is the default index. |
protected QueryEngine |
queryEngine
The query engine. |
protected String |
template
The actual template used by this servlet (default: DEFAULT_TEMPLATE ). |
protected List<CharSequence> |
titleList
An optional title list if the document collection is not present. |
Fields inherited from class org.apache.velocity.tools.view.servlet.VelocityViewServlet |
---|
CONTENT_TYPE, DEFAULT_CONTENT_TYPE, DEFAULT_OUTPUT_ENCODING, DEFAULT_PROPERTIES_PATH, DEFAULT_TOOLBOX_PATH, DEFAULT_TOOLS_PROPERTIES, INIT_PROPS_KEY, SERVLET_CONTEXT_KEY, TOOLBOX_KEY, toolboxManager |
Constructor Summary | |
---|---|
QueryServlet()
|
Method Summary | |
---|---|
Template |
handleRequest(HttpServletRequest request,
HttpServletResponse response,
Context context)
|
void |
init()
|
Methods inherited from class org.apache.velocity.tools.view.servlet.VelocityViewServlet |
---|
createContext, doGet, doPost, doRequest, error, findInitParameter, getResponseWriter, getTemplate, getTemplate, getVelocityEngine, getVelocityProperty, init, initToolbox, initVelocity, loadConfiguration, mergeTemplate, performMerge, requestCleanup, setContentType, setVelocityEngine |
Methods inherited from class javax.servlet.http.HttpServlet |
---|
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
---|
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, log, log |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String DEFAULT_TEMPLATE
protected String template
DEFAULT_TEMPLATE
).
protected QueryEngine queryEngine
protected DocumentCollection documentCollection
protected List<CharSequence> titleList
protected Object2ReferenceMap<String,Index> indexMap
Constructor Detail |
---|
public QueryServlet()
Method Detail |
---|
public void init() throws ServletException
init
in class GenericServlet
ServletException
public Template handleRequest(HttpServletRequest request, HttpServletResponse response, Context context)
handleRequest
in class VelocityViewServlet
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |