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, 34 String[] paramNames, 35 String[] paramValues, 36 PrintWriter writer) { Rate37 38 String configErrMsg = ssiMediator.getConfigErrMsg(); Rate39 40 for ( int i=0; i < paramNames.length; i++ ) { 41 String paramName = paramNames[i]; 42 String paramValue = paramValues[i]; 43 44 try { 45 if ( paramName.equalsIgnoreCase("file") || 46 paramName.equalsIgnoreCase("virtual") ) { 47 boolean virtual = paramName.equalsIgnoreCase("virtual"); 48 String text = ssiMediator.getFileText( paramValue, virtual ); 49 writer.write( text ); 50 } else { 51 ssiMediator.log("#include--Invalid attribute: " + paramName ); 52 writer.write( configErrMsg ); 53 } 54 } catch ( IOException e ) { 55 ssiMediator.log("#include--Couldn't include file: " + paramValue, e ); 56 writer.write( configErrMsg ); 57 } 58 } 59 } 60 }