Processes the echo directive to output the value of a server variable.
(SSIMediator ssiMediator, String commandName, String[] paramNames, String[] paramValues,
PrintWriter writer)
| 47 | * Processes the echo directive to output the value of a server variable. |
| 48 | */ |
| 49 | @Override |
| 50 | public long process(SSIMediator ssiMediator, String commandName, String[] paramNames, String[] paramValues, |
| 51 | PrintWriter writer) { |
| 52 | String encoding = DEFAULT_ENCODING; |
| 53 | String originalValue = null; |
| 54 | String errorMessage = ssiMediator.getConfigErrMsg(); |
| 55 | for (int i = 0; i < paramNames.length; i++) { |
| 56 | String paramName = paramNames[i]; |
| 57 | String paramValue = paramValues[i]; |
| 58 | if (paramName.equalsIgnoreCase("var")) { |
| 59 | originalValue = paramValue; |
| 60 | } else if (paramName.equalsIgnoreCase("encoding")) { |
| 61 | if (isValidEncoding(paramValue)) { |
| 62 | encoding = paramValue; |
| 63 | } else { |
| 64 | ssiMediator.log(sm.getString("ssiEcho.invalidEncoding", paramValue)); |
| 65 | writer.write(ssiMediator.encode(errorMessage, SSIMediator.ENCODING_ENTITY)); |
| 66 | } |
| 67 | } else { |
| 68 | ssiMediator.log(sm.getString("ssiCommand.invalidAttribute", paramName)); |
| 69 | writer.write(ssiMediator.encode(errorMessage, SSIMediator.ENCODING_ENTITY)); |
| 70 | } |
| 71 | } |
| 72 | String variableValue = (originalValue == null) ? MISSING_VARIABLE_VALUE : |
| 73 | ssiMediator.getVariableValue(originalValue, encoding); |
| 74 | if (variableValue == null) { |
| 75 | variableValue = MISSING_VARIABLE_VALUE; |
| 76 | } |
| 77 | writer.write(variableValue); |
| 78 | return System.currentTimeMillis(); |
| 79 | } |
| 80 | |
| 81 | |
| 82 | /** |
nothing calls this directly
no test coverage detected