Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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.
Fields inherited from class | Fields |
---|---|
class AbstractHttpServlet |
CONTENT_TYPE_TEXT_HTML, INC_PATH_INFO, INC_REQUEST_URI, INC_SERVLET_PATH, INIT_PARAM_RESOURCE_NAME_REGEX, INIT_PARAM_RESOURCE_NAME_REGEX_FLAGS, encoding, namePrefix, reflection, resourceNamePattern, resourceNameReplaceAll, resourceNameReplacement, servletContext, verbose |
Type | Name and description |
---|---|
def |
TemplateServlet() Create new TemplateServlet. |
protected Template |
getTemplate(File file) Gets the template created by the underlying engine parsing the request. |
protected Template |
getTemplate(URL url) Gets the template created by the underlying engine parsing the request. |
void |
init(ServletConfig config) Initializes the servlet from hints the container passes. |
protected TemplateEngine |
initTemplateEngine(ServletConfig config) Creates the template engine. |
void |
service(HttpServletRequest request, HttpServletResponse response) Services the request with a response. |
Methods inherited from class | Name |
---|---|
class AbstractHttpServlet |
applyResourceNameMatcher, generateNamePrefixOnce, getResourceConnection, getScriptUri, getScriptUriAsFile, init, removeNamePrefix, setVariables |
Create new TemplateServlet.
Gets the template created by the underlying engine parsing the request.
This method looks up a simple (weak) hash map for an existing template object that matches the source file. If the source file didn't change in length and its last modified stamp hasn't changed compared to a precompiled template object, this template is used. Otherwise, there is no or an invalid template object cache entry, a new one is created by the underlying template engine. This new instance is put to the cache for consecutive calls.
file
- The file containing the template source.Gets the template created by the underlying engine parsing the request.
This method looks up a simple (weak) hash map for an existing template object that matches the source URL. If there is no cache entry, a new one is created by the underlying template engine. This new instance is put to the cache for consecutive calls.
url
- The URL containing the template source..Initializes the servlet from hints the container passes.
Delegates to sub-init methods and parses the following parameters:
config
- Passed by the servlet container.Creates the template engine.
Called by TemplateServlet.init and returns just
new groovy.text.SimpleTemplateEngine()
if the init parameter
template.engine
is not set by the container configuration.
config
- Current servlet configuration passed by the container.null
on error.Services the request with a response.
First the request is parsed for the source file uri. If the specified file could not be found or can not be read an error message is sent as response.
request
- The http request.response
- The http response.