FileDocCategorySizeDatePackage
SSIEcho.javaAPI DocApache Tomcat 6.0.142992Fri Jul 20 04:20:34 BST 2007org.apache.catalina.ssi

SSIEcho

public class SSIEcho extends Object implements SSICommand
Return the result associated with the supplied Server Variable.
author
Bip Thelin
author
Paul Speed
author
Dan Sandberg
author
David Becker
version
$Revision: 531303 $, $Date: 2007-04-23 02:24:01 +0200 (lun., 23 avr. 2007) $

Fields Summary
protected static final String
DEFAULT_ENCODING
protected static final String
MISSING_VARIABLE_VALUE
Constructors Summary
Methods Summary
protected booleanisValidEncoding(java.lang.String encoding)

        return encoding.equalsIgnoreCase("url")
                || encoding.equalsIgnoreCase("entity")
                || encoding.equalsIgnoreCase("none");
    
public longprocess(SSIMediator ssiMediator, java.lang.String commandName, java.lang.String[] paramNames, java.lang.String[] paramValues, java.io.PrintWriter writer)

see
SSICommand



           
         
                  
    	long lastModified = 0;
        String encoding = DEFAULT_ENCODING;
        String errorMessage = ssiMediator.getConfigErrMsg();
        for (int i = 0; i < paramNames.length; i++) {
            String paramName = paramNames[i];
            String paramValue = paramValues[i];
            if (paramName.equalsIgnoreCase("var")) {
                String variableValue = ssiMediator.getVariableValue(
                        paramValue, encoding);
                if (variableValue == null) {
                    variableValue = MISSING_VARIABLE_VALUE;
                }
                writer.write(variableValue);
                lastModified = System.currentTimeMillis();
            } else if (paramName.equalsIgnoreCase("encoding")) {
                if (isValidEncoding(paramValue)) {
                    encoding = paramValue;
                } else {
                    ssiMediator.log("#echo--Invalid encoding: " + paramValue);
                    writer.write(errorMessage);
                }
            } else {
                ssiMediator.log("#echo--Invalid attribute: " + paramName);
                writer.write(errorMessage);
            }
        }
        return lastModified;