1 6 7 package org.netbeans.modules.exceptions; 8 9 import java.io.DataInputStream ; 10 import java.io.DataOutputStream ; 11 import java.io.IOException ; 12 import java.io.PrintWriter ; 13 import java.sql.ResultSet ; 14 import java.sql.SQLException ; 15 import java.sql.Statement ; 16 import java.util.logging.Level ; 17 import java.util.logging.Logger ; 18 import javax.servlet.*; 19 import javax.servlet.http.*; 20 21 26 public class CheckingServlet extends HttpServlet { 27 31 protected void processRequest(HttpServletRequest request, HttpServletResponse response) 32 throws ServletException, IOException { 33 response.setContentType("text/html;charset=UTF-8"); 34 PrintWriter out = response.getWriter(); 35 45 out.close(); 46 } 47 48 protected void doPut(HttpServletRequest request, HttpServletResponse response) 49 throws ServletException, IOException { 50 try{ 51 DataInputStream istream = new DataInputStream (request.getInputStream()); 52 int vstup = istream.readInt(); 53 Statement stmt = Utils.getConnection().createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); 54 String query = Utils.SELECT_HASH+Integer.toString(vstup); 55 ResultSet result = Utils.executeQuery(stmt, query); 56 boolean found = result.next(); 57 int issueId=0; 58 DataOutputStream resp = new DataOutputStream (response.getOutputStream()); 59 if (found){ 60 issueId = result.getInt(2); 61 resp.writeInt(issueId); 62 Logger.getLogger(LoadingServlet.class.getName()).log(Level.FINEST, 63 "Throwable "+Integer.toString(issueId) +" was checked"); 64 } else{ 65 resp.writeInt(-1); Logger.getLogger(LoadingServlet.class.getName()).log(Level.FINER, 67 "Throwable not found"); 68 } 69 stmt.close(); 70 resp.flush(); 71 resp.close(); 72 } catch (IOException ex) { 73 java.util.logging.Logger.getLogger(ComponentsServlet.class.getName()).log(java.util.logging.Level.SEVERE, 74 ex.getMessage(), ex); 75 } catch (SQLException ex) { 76 java.util.logging.Logger.getLogger(ComponentsServlet.class.getName()).log(java.util.logging.Level.SEVERE, 77 ex.getMessage(), ex); 78 }; 79 } 80 85 protected void doGet(HttpServletRequest request, HttpServletResponse response) 86 throws ServletException, IOException { 87 processRequest(request, response); 88 } 89 90 94 protected void doPost(HttpServletRequest request, HttpServletResponse response) 95 throws ServletException, IOException { 96 processRequest(request, response); 97 } 98 99 101 public String getServletInfo() { 102 return "Short description"; 103 } 104 } 106 | Popular Tags |