01: /*
02: * Copyright 2002-2005 the original author or authors.
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.springframework.web.servlet.tags;
18:
19: import javax.servlet.jsp.JspException;
20:
21: import org.springframework.web.util.ExpressionEvaluationUtils;
22:
23: /**
24: * Sets default HTML escape value for the current page. The actual value
25: * can be overridden by escaping-aware tags. The default is "false".
26: *
27: * <p>Note: You can also set a "defaultHtmlEscape" web.xml context-param.
28: * A page-level setting overrides a context-param.
29: *
30: * @author Juergen Hoeller
31: * @since 04.03.2003
32: * @see HtmlEscapingAwareTag#setHtmlEscape
33: */
34: public class HtmlEscapeTag extends RequestContextAwareTag {
35:
36: private String defaultHtmlEscape;
37:
38: /**
39: * Set the default value for HTML escaping,
40: * to be put into the current PageContext.
41: */
42: public void setDefaultHtmlEscape(String defaultHtmlEscape) {
43: this .defaultHtmlEscape = defaultHtmlEscape;
44: }
45:
46: protected int doStartTagInternal() throws JspException {
47: boolean resolvedDefaultHtmlEscape = ExpressionEvaluationUtils
48: .evaluateBoolean("defaultHtmlEscape",
49: this.defaultHtmlEscape, pageContext);
50: getRequestContext().setDefaultHtmlEscape(
51: resolvedDefaultHtmlEscape);
52: return EVAL_BODY_INCLUDE;
53: }
54:
55: }
|