SSIEchopublic class SSIEcho extends Object implements SSICommandReturn the result associated with the supplied Server Variable. |
Fields Summary |
---|
protected static final String | DEFAULT_ENCODING | protected static final String | MISSING_VARIABLE_VALUE |
Methods Summary |
---|
protected boolean | isValidEncoding(java.lang.String encoding)
return encoding.equalsIgnoreCase("url")
|| encoding.equalsIgnoreCase("entity")
|| encoding.equalsIgnoreCase("none");
| public long | process(SSIMediator ssiMediator, java.lang.String commandName, java.lang.String[] paramNames, java.lang.String[] paramValues, java.io.PrintWriter writer)
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;
|
|