01: /*
02: * Copyright 1999,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.catalina.ssi;
18:
19: import java.io.IOException;
20: import java.io.PrintWriter;
21:
22: /**
23: * Implements the Server-side #include command
24: *
25: * @author Bip Thelin
26: * @author Dan Sandberg
27: * @version $Revision: 1.3 $, $Date: 2004/02/27 14:58:47 $
28: */
29: public final class SSIInclude implements SSICommand {
30: /**
31: * @see SSICommand
32: */
33: public void process(SSIMediator ssiMediator, String[] paramNames,
34: String[] paramValues, PrintWriter writer) {
35:
36: String configErrMsg = ssiMediator.getConfigErrMsg();
37:
38: for (int i = 0; i < paramNames.length; i++) {
39: String paramName = paramNames[i];
40: String paramValue = paramValues[i];
41:
42: try {
43: if (paramName.equalsIgnoreCase("file")
44: || paramName.equalsIgnoreCase("virtual")) {
45: boolean virtual = paramName
46: .equalsIgnoreCase("virtual");
47: String text = ssiMediator.getFileText(paramValue,
48: virtual);
49: writer.write(text);
50: } else {
51: ssiMediator.log("#include--Invalid attribute: "
52: + paramName);
53: writer.write(configErrMsg);
54: }
55: } catch (IOException e) {
56: ssiMediator.log("#include--Couldn't include file: "
57: + paramValue, e);
58: writer.write(configErrMsg);
59: }
60: }
61: }
62: }
|