1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 package org.w3c.tidy.servlet.jsp.tagext;
56
57 import java.io.IOException;
58
59 import javax.servlet.jsp.JspException;
60 import javax.servlet.jsp.tagext.TagSupport;
61
62 import org.apache.commons.logging.Log;
63 import org.apache.commons.logging.LogFactory;
64
65 import org.w3c.tidy.servlet.reports.Report;
66
67
68 /***
69 * Print the same report as TidyServlet base on JTidy HTML Validation See tagExample.jsp for usage example.
70 * @author Vlad Skarzhevskyy <a href="mailto:skarzhevskyy@gmail.com">skarzhevskyy@gmail.com </a>
71 * @version $Revision: 1.8 $ ($Author: fgiust $)
72 */
73 public class ReportTag extends TagSupport
74 {
75
76 /***
77 * Stable <code>serialVersionUID</code>.
78 */
79 private static final long serialVersionUID = 29137L;
80
81 private boolean source = true;
82
83 private boolean result = false;
84
85 private boolean wrapSource = true;
86
87 private int wrapLen = 0;
88
89 private String requestID = null;
90
91 /***
92 * logger.
93 */
94 private static Log log = LogFactory.getLog(ReportTag.class);
95
96 /***
97 * {@inheritDoc}
98 */
99 public int doEndTag() throws JspException
100 {
101 try
102 {
103 Report report = new Report(pageContext.getSession());
104
105 report.setCompletePage(false);
106 report.setPrintSource(this.source);
107 report.setPrintHtmlResult(this.result);
108 report.setWrapSource(this.wrapSource);
109 report.setWrapLen(this.wrapLen);
110 report.print(pageContext.getOut(), this.requestID);
111
112 }
113 catch (IOException e)
114 {
115 log.error("ReportTag write error", e);
116 throw new JspException(e.getMessage());
117 }
118 return EVAL_PAGE;
119 }
120
121 /***
122 * {@inheritDoc}
123 */
124 public void release()
125 {
126 super.release();
127
128 this.source = true;
129 this.wrapSource = true;
130 this.requestID = null;
131 this.result = false;
132 }
133
134 /***
135 * @param requestID The requestID to set.
136 */
137 public void setRequestID(String requestID)
138 {
139 this.requestID = requestID;
140 }
141
142 /***
143 * @param source The source to set.
144 */
145 public void setSource(boolean source)
146 {
147 log.debug("Set source:" + source);
148 this.source = source;
149 }
150
151 /***
152 * @param wrapSource The wrapSource to set.
153 */
154 public void setWrapSource(boolean wrapSource)
155 {
156 this.wrapSource = wrapSource;
157 }
158
159 /***
160 * @param wrapLen The wrapLen to set.
161 */
162 public void setWrapLen(int wrapLen)
163 {
164 this.wrapLen = wrapLen;
165 }
166
167 /***
168 * @param result The result to set.
169 */
170 public void setResult(boolean result)
171 {
172 this.result = result;
173 }
174
175 }