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.PrintWriter;
20: import java.util.Collection;
21: import java.util.Iterator;
22:
23: /**
24: * Implements the Server-side #printenv command
25: *
26: * @author Dan Sandberg
27: * @version $Revision: 1.2 $, $Date: 2004/02/27 14:58:47 $
28: */
29: public class SSIPrintenv implements SSICommand {
30: /**
31: * @see SSICommand
32: */
33: public void process(SSIMediator ssiMediator, String[] paramNames,
34: String[] paramValues, PrintWriter writer) {
35:
36: //any arguments should produce an error
37: if (paramNames.length > 0) {
38: String errorMessage = ssiMediator.getConfigErrMsg();
39: writer.write(errorMessage);
40: } else {
41: Collection variableNames = ssiMediator.getVariableNames();
42: Iterator iter = variableNames.iterator();
43: while (iter.hasNext()) {
44: String variableName = (String) iter.next();
45: String variableValue = ssiMediator
46: .getVariableValue(variableName);
47: //This shouldn't happen, since all the variable names must have values
48: if (variableValue == null) {
49: variableValue = "(none)";
50: }
51: writer.write(variableName);
52: writer.write('=');
53: writer.write(variableValue);
54: writer.write('\n');
55: }
56: }
57: }
58: }
|