KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > ssi > SSIPrintenv


1 /*
2  * Copyright 1999,2004 The Apache Software Foundation. Licensed under the
3  * Apache License, Version 2.0 (the "License"); you may not use this file
4  * except in compliance with the License. You may obtain a copy of the License
5  * at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
6  * law or agreed to in writing, software distributed under the License is
7  * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8  * KIND, either express or implied. See the License for the specific language
9  * governing permissions and limitations under the License.
10  */

11 package org.apache.catalina.ssi;
12
13
14 import java.io.PrintWriter JavaDoc;
15 import java.util.Collection JavaDoc;
16 import java.util.Iterator JavaDoc;
17 /**
18  * Implements the Server-side #printenv command
19  *
20  * @author Dan Sandberg
21  * @author David Becker
22  * @version $Revision: 467222 $, $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
23  */

24 public class SSIPrintenv implements SSICommand {
25     /**
26      * @see SSICommand
27      */

28     public long process(SSIMediator ssiMediator, String JavaDoc commandName,
29             String JavaDoc[] paramNames, String JavaDoc[] paramValues, PrintWriter JavaDoc writer) {
30         long lastModified = 0;
31         //any arguments should produce an error
32
if (paramNames.length > 0) {
33             String JavaDoc errorMessage = ssiMediator.getConfigErrMsg();
34             writer.write(errorMessage);
35         } else {
36             Collection JavaDoc variableNames = ssiMediator.getVariableNames();
37             Iterator JavaDoc iter = variableNames.iterator();
38             while (iter.hasNext()) {
39                 String JavaDoc variableName = (String JavaDoc)iter.next();
40                 String JavaDoc variableValue = ssiMediator
41                         .getVariableValue(variableName);
42                 //This shouldn't happen, since all the variable names must
43
// have values
44
if (variableValue == null) {
45                     variableValue = "(none)";
46                 }
47                 writer.write(variableName);
48                 writer.write('=');
49                 writer.write(variableValue);
50                 writer.write('\n');
51                 lastModified = System.currentTimeMillis();
52             }
53         }
54         return lastModified;
55     }
56 }
57
Popular Tags