1 19 20 29 30 package org.netbeans.modules.web.monitor.server; 31 32 import java.io.*; 33 import java.net.*; 34 import java.util.*; 35 import java.text.*; 36 import javax.servlet.*; 37 import javax.servlet.http.*; 38 39 public class MonitorResponseWrapper extends HttpServletResponseWrapper { 40 41 private Vector cookies = null; 42 private int status; 43 private boolean cookieSetOnInclude = false; 44 45 private HttpServletResponse response = null; 46 private HttpServletRequest request = null; 47 48 private static boolean debug = false; 49 50 62 public MonitorResponseWrapper(HttpServletResponse response, 63 HttpServletRequest request) { 64 super(response); 65 this.response = (HttpServletResponse)getResponse(); 66 this.request = request; 67 cookies = new Vector(); 68 } 69 70 77 public Enumeration getCookies() { 78 return cookies.elements(); 79 } 80 81 87 public int getStatus() { 88 return status; 89 } 90 91 92 101 public void addCookie (Cookie cookie) { 102 String str = (String )request.getAttribute("javax.servlet.include.request_uri"); if(str == null) { 104 cookies.add(cookie); 105 response.addCookie(cookie); 106 } 107 else { 108 cookieSetOnInclude = true; 111 } 112 } 113 114 124 public void sendError (int status, String detail) throws 125 IOException, IllegalStateException { 126 this.status = status; 127 response.sendError (status, detail); 128 } 129 130 139 public void sendError (int status) throws IOException, 140 IllegalStateException { 141 this.status = status; 142 response.sendError (status, null); 143 } 144 145 154 public void setStatus(int code) { 155 this.status = code; 156 response.setStatus(code); 157 } 158 159 169 public void setStatus (int code, String msg) { 170 this.status = code; 171 response.setStatus(code, msg); 172 } 173 174 181 private void log(String msg) { 182 try { 183 request.getSession(false).getServletContext().log("MonitorResponseWrapper::" + msg); } 185 catch(Throwable t) { 186 if(debug) t.printStackTrace(); 187 } 188 } 189 190 198 public boolean cookieSetOnInclude() { 199 return cookieSetOnInclude; 200 } 201 } | Popular Tags |