1 19 24 25 package org.netbeans.modules.exceptions; 26 27 import java.io.IOException ; 28 import java.io.PrintWriter ; 29 import java.sql.ResultSet ; 30 import java.sql.SQLException ; 31 import java.sql.Statement ; 32 import javax.servlet.ServletException ; 33 import javax.servlet.http.HttpServlet ; 34 import javax.servlet.http.HttpServletRequest ; 35 import javax.servlet.http.HttpServletResponse ; 36 import static org.netbeans.modules.exceptions.Utils.*; 37 42 public class ShowServlet extends HttpServlet { 43 private PrintWriter out; 44 private String param; 45 46 50 protected void processRequest(HttpServletRequest request, HttpServletResponse response) 51 throws ServletException , IOException { 52 out = response.getWriter(); 53 ResultSet result = null; 54 param = request.getParameter("param"); 55 try { 56 response.setContentType("text/html;charset=UTF-8"); 57 Class.forName("org.apache.derby.jdbc.ClientDriver"); 58 Statement stmt = Utils.getConnection().createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); 59 stmt.setEscapeProcessing(false); 60 result = Utils.executeQuery(stmt, "SELECT * FROM "+param); 61 out.println("<table border=\"1\"><thead>"); 62 if (param.equals(PARAM_SHOW_LINE)) { 63 out.println("<td>StackTrace ID</td>"); 64 out.println("<td>Method Id</td>"); 65 out.println("<td>File Id</td>"); 66 out.println("<td>Line Number</td>"); 67 out.println("<td>Line Order</td></thead>"); 68 printTab(result, 5); 69 } else if (param.equals(PARAM_SHOW_COMMENT)) { 70 out.println("<td>Comment ID</td>"); 71 out.println("<td>Issue Id</td>"); 72 out.println("<td>NbUser Id</td>"); 73 out.println("<td>Comment</td></thead>"); 74 printTab(result, 4); 75 } else if (param.equals(PARAM_SHOW_ISSUENBUSER)) { 76 out.println("<td>Issue Id</td>"); 77 out.println("<td>User Id</td>"); 78 out.println("<td>Date + Time</td></thead>"); 79 printTab(result, 3); 80 } else if (param.equals(PARAM_SHOW_ISSUE)) { 81 out.println("<td>Issue Id</td>"); 82 out.println("<td>Summary</td>"); 83 out.println("<td>Logger name</td>"); 84 out.println("<td>VM</td>"); 85 out.println("<td>Product version</td>"); 86 out.println("<td>Component</td>"); 87 out.println("<td>SubComponent</td>"); 88 out.println("<td>AssignTo</td>"); 89 out.println("<td>Operating system</td>"); 90 out.println("<td>Severity</td>"); 91 out.println("<td>Link</td></thead>"); 92 printTab(result, 10); 93 } else if (param.equals(PARAM_SHOW_STACKTRACE)) { 94 out.println("<td>StackTrace ID</td>"); 95 out.println("<td>Message</td>"); 96 out.println("<td>Class name</td>"); 97 out.println("<td>Annotation</td></thead>"); 98 printTab(result, 4); 99 } else if (param.equals(PARAM_SHOW_METHOD)){ 100 out.println("<td>Method ID</td>"); 101 out.println("<td>Method name</td></thead>"); 102 printTab(result, 2); 103 } else if (param.equals(PARAM_SHOW_NBFILES)){ 104 out.println("<td>File ID</td>"); 105 out.println("<td>File name</td></thead>"); 106 printTab(result, 2); 107 } else if (param.equals(PARAM_SHOW_NBUSER)) { 108 out.println("<td>User ID</td>"); 109 out.println("<td>User name</td></thead>"); 110 printTab(result, 2); 111 } else if (param.equals(PARAM_SHOW_LOGGER)) { 112 out.println("<td>Log ID</td>"); 113 out.println("<td>Log content</td></thead>"); 114 printTab(result, 1); 115 } else { 116 out.println("ILLEGAL ARGUMENT"); 117 } 118 out.println("</table>"); 119 stmt.close(); 120 } catch (SQLException ex) { 121 java.util.logging.Logger.getLogger(ShowServlet.class.getName()).log(java.util.logging.Level.SEVERE, 122 ex.getMessage(), ex); 123 } catch (ClassNotFoundException ex) { 124 java.util.logging.Logger.getLogger(ShowServlet.class.getName()).log(java.util.logging.Level.SEVERE, 125 ex.getMessage(), ex); 126 }; 127 128 } 129 130 public void printTab(ResultSet result, int columnsCount) throws SQLException , IOException , ClassNotFoundException { 131 String str; 132 int j; 133 while (result.next()){ 134 out.write("<tr>"); 135 for (j=1;j<=columnsCount;j++){ 136 out.write("<td>"); 137 str = result.getString(j); 138 if (str == null) str = "null"; 139 out.write(str); 140 out.write("</td>\n"); 141 } 142 if (param.equals(PARAM_SHOW_ISSUE)){ 143 out.write("<td>"); 144 out.write("<a HREF=Select.jsp?"+SelectIssue.ID_PARAM+"="+result.getString(1)+">show</a>"); 145 out.write("</td>\n"); 146 } 147 if (param.equals(PARAM_SHOW_LOGGER)){ 148 String loggerText= Utils.getHTMLLog(result); 149 out.write("<td>"+loggerText+"</td>"); 150 } 151 out.write("</tr>\n"); 152 } 153 154 } 155 156 161 protected void doGet(HttpServletRequest request, HttpServletResponse response) 162 throws ServletException , IOException { 163 processRequest(request, response); 164 } 165 166 170 protected void doPost(HttpServletRequest request, HttpServletResponse response) 171 throws ServletException , IOException { 172 processRequest(request, response); 173 } 174 175 177 public String getServletInfo() { 178 return "Short description"; 179 } 180 } 182 | Popular Tags |