1 19 20 package org.netbeans.modules.web.monitor.client; 21 22 import java.io.*; 23 import java.text.*; 24 import java.util.Enumeration ; 25 import java.util.StringTokenizer ; 26 import javax.servlet.*; 27 import javax.servlet.http.*; 28 29 import org.netbeans.modules.web.monitor.data.MonitorData; 30 31 import org.openide.filesystems.FileObject; 32 import org.openide.filesystems.FileLock; 33 34 37 38 public class ReplaySendXMLServlet extends HttpServlet { 39 40 41 private static FileObject currDir = null; 42 private static FileObject saveDir = null; 43 private static FileObject replayDir = null; 44 private final static boolean debug = false; 45 46 47 public void doPost(HttpServletRequest req, HttpServletResponse res) 51 throws ServletException, IOException { 52 53 if(debug) 54 System.out.println("\n\nReplaySendXMLServlet: DoPost.\n\n"); PrintWriter out = res.getWriter(); 56 try { 57 out.println("Shouldn't use POST for this!"); } 59 catch (Exception e) { 60 } 61 try { out.close(); } catch(Exception ex) {} 62 } 63 64 public void doGet(HttpServletRequest req, HttpServletResponse res) 67 throws ServletException, IOException { 68 69 if(debug) System.out.println("\n\nReplaySendXMLServlet: DoGet.\n\n"); 71 String status = null; 72 String id = null; 73 74 try { 75 status = req.getParameter("status"); id = req.getParameter("id"); if(debug) 78 System.out.println("\n\nReplaySendXMLServlet: id=" + id + " ,status=" + status); } 81 catch(Exception ex) { 82 return; 84 } 85 86 Controller controller = MonitorAction.getController(); 87 MonitorData md = controller.retrieveMonitorData(id, status); 88 if(md != null) { 89 90 Util.setSessionCookieHeader(md); 91 String method = 92 md.getRequestData().getAttributeValue("method"); 94 if(method.equals("POST")) { Util.removeParametersFromQuery(md.getRequestData()); 96 } 97 else if(method.equals("GET")) { Util.composeQueryString(md.getRequestData()); 99 } 100 101 res.addHeader("Content-type", "text/plain;charset=\"UTF-8\""); 104 PrintWriter out = res.getWriter(); 105 try { 106 md.write(out); 107 } 108 catch(NullPointerException npe) { 109 if(debug) npe.printStackTrace(); 110 } 111 catch(IOException ioe) { 112 if(debug) ioe.printStackTrace(); 113 } 114 catch(Throwable t) { 115 if(debug) t.printStackTrace(); 116 } 117 finally { 118 try { 120 out.close(); 121 } 122 catch(Exception ex) { 123 } 124 } 125 } 126 if(debug) { 127 try { 128 StringBuffer buf = new StringBuffer 129 (System.getProperty("java.io.tmpdir")); buf.append(System.getProperty("file.separator")); buf.append("replay-servlet.xml"); File file = new File(buf.toString()); 133 log("Writing replay data to " + file.getAbsolutePath()); 135 FileOutputStream fout = new FileOutputStream(file); 136 PrintWriter pw2 = new PrintWriter(fout); 137 md.write(pw2); 138 pw2.close(); 139 fout.close(); 140 141 } 142 catch(Throwable t) { 143 } 144 } 145 146 if(debug) 147 System.out.println("ReplaySendXMLServlet doGet exiting..."); } 149 } 151 152 153 | Popular Tags |