1 17 18 19 package org.apache.catalina.core; 20 21 22 import java.io.IOException ; 23 import java.util.Locale ; 24 25 import javax.servlet.http.Cookie ; 26 import javax.servlet.http.HttpServletResponse ; 27 import javax.servlet.http.HttpServletResponseWrapper ; 28 29 import org.apache.catalina.util.StringManager; 30 31 32 47 48 class ApplicationHttpResponse extends HttpServletResponseWrapper { 49 50 51 53 54 59 public ApplicationHttpResponse(HttpServletResponse response) { 60 61 this(response, false); 62 63 } 64 65 66 73 public ApplicationHttpResponse(HttpServletResponse response, 74 boolean included) { 75 76 super(response); 77 setIncluded(included); 78 79 } 80 81 82 84 85 89 protected boolean included = false; 90 91 92 95 protected static final String info = 96 "org.apache.catalina.core.ApplicationHttpResponse/1.0"; 97 98 99 102 protected static StringManager sm = 103 StringManager.getManager(Constants.Package); 104 105 106 108 109 115 public void reset() { 116 117 if (!included || getResponse().isCommitted()) 119 getResponse().reset(); 120 121 } 122 123 124 129 public void setContentLength(int len) { 130 131 if (!included) 132 getResponse().setContentLength(len); 133 134 } 135 136 137 142 public void setContentType(String type) { 143 144 if (!included) 145 getResponse().setContentType(type); 146 147 } 148 149 150 155 public void setLocale(Locale loc) { 156 157 if (!included) 158 getResponse().setLocale(loc); 159 160 } 161 162 163 168 public void setBufferSize(int size) { 169 if (!included) 170 getResponse().setBufferSize(size); 171 } 172 173 174 176 177 182 public void addCookie(Cookie cookie) { 183 184 if (!included) 185 ((HttpServletResponse ) getResponse()).addCookie(cookie); 186 187 } 188 189 190 196 public void addDateHeader(String name, long value) { 197 198 if (!included) 199 ((HttpServletResponse ) getResponse()).addDateHeader(name, value); 200 201 } 202 203 204 210 public void addHeader(String name, String value) { 211 212 if (!included) 213 ((HttpServletResponse ) getResponse()).addHeader(name, value); 214 215 } 216 217 218 224 public void addIntHeader(String name, int value) { 225 226 if (!included) 227 ((HttpServletResponse ) getResponse()).addIntHeader(name, value); 228 229 } 230 231 232 239 public void sendError(int sc) throws IOException { 240 241 if (!included) 242 ((HttpServletResponse ) getResponse()).sendError(sc); 243 244 } 245 246 247 255 public void sendError(int sc, String msg) throws IOException { 256 257 if (!included) 258 ((HttpServletResponse ) getResponse()).sendError(sc, msg); 259 260 } 261 262 263 270 public void sendRedirect(String location) throws IOException { 271 272 if (!included) 273 ((HttpServletResponse ) getResponse()).sendRedirect(location); 274 275 } 276 277 278 284 public void setDateHeader(String name, long value) { 285 286 if (!included) 287 ((HttpServletResponse ) getResponse()).setDateHeader(name, value); 288 289 } 290 291 292 298 public void setHeader(String name, String value) { 299 300 if (!included) 301 ((HttpServletResponse ) getResponse()).setHeader(name, value); 302 303 } 304 305 306 312 public void setIntHeader(String name, int value) { 313 314 if (!included) 315 ((HttpServletResponse ) getResponse()).setIntHeader(name, value); 316 317 } 318 319 320 325 public void setStatus(int sc) { 326 327 if (!included) 328 ((HttpServletResponse ) getResponse()).setStatus(sc); 329 330 } 331 332 333 339 public void setStatus(int sc, String msg) { 340 341 if (!included) 342 ((HttpServletResponse ) getResponse()).setStatus(sc, msg); 343 344 } 345 346 347 349 350 353 public String getInfo() { 354 355 return (info); 356 357 } 358 359 360 363 boolean isIncluded() { 364 365 return (this.included); 366 367 } 368 369 370 375 void setIncluded(boolean included) { 376 377 this.included = included; 378 379 } 380 381 382 387 void setResponse(HttpServletResponse response) { 388 389 super.setResponse(response); 390 391 } 392 393 394 } 395 | Popular Tags |