/* * 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.
*/ package org.apache.catalina.ssi;
if (debug > 0) {
log("SSIServlet.init() SSI invoker started with 'debug'=" + debug);
}
}
/** * Process and forward the GET request to our <code>requestHandler()</code>* * * @param req * a value of type 'HttpServletRequest' * @param res * a value of type 'HttpServletResponse' * @exception IOException * if an error occurs * @exception ServletException * if an error occurs
*/
@Override publicvoid doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { if (debug > 0) {
log("SSIServlet.doGet()");
}
requestHandler(req, res);
}
/** * Process and forward the POST request to our * <code>requestHandler()</code>. * * @param req * a value of type 'HttpServletRequest' * @param res * a value of type 'HttpServletResponse' * @exception IOException * if an error occurs * @exception ServletException * if an error occurs
*/
@Override publicvoid doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { if (debug > 0) {
log("SSIServlet.doPost()");
}
requestHandler(req, res);
}
/** * Process our request and locate right SSI command. * * @param req * a value of type 'HttpServletRequest' * @param res * a value of type 'HttpServletResponse' * @throws IOException an IO error occurred
*/ protectedvoid requestHandler(HttpServletRequest req,
HttpServletResponse res) throws IOException {
ServletContext servletContext = getServletContext();
String path = SSIServletRequestUtil.getRelativePath(req); if (debug > 0) {
log("SSIServlet.requestHandler()\n" + "Serving "
+ (buffered?"buffered ":"unbuffered ") + "resource '"
+ path + "'");
} // Exclude any resource in the /WEB-INF and /META-INF subdirectories // (the "toUpperCase()" avoids problems on Windows systems) if (path == null || path.toUpperCase(Locale.ENGLISH).startsWith("/WEB-INF")
|| path.toUpperCase(Locale.ENGLISH).startsWith("/META-INF")) {
res.sendError(HttpServletResponse.SC_NOT_FOUND); return;
}
URL resource = servletContext.getResource(path); if (resource == null) {
res.sendError(HttpServletResponse.SC_NOT_FOUND); return;
}
String resourceMimeType = servletContext.getMimeType(path); if (resourceMimeType == null) {
resourceMimeType = "text/html";
}
res.setContentType(resourceMimeType + ";charset=" + outputEncoding); if (expires != null) {
res.setDateHeader("Expires", (new java.util.Date()).getTime()
+ expires.longValue() * 1000);
}
processSSI(req, res, resource);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.