KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > exceptions > ComponentsServlet


1 /*
2  * ComponentsServlet.java
3  *
4  * Created on December 11, 2006, 7:38 PM
5  */

6
7 package org.netbeans.modules.exceptions;
8
9 import java.io.IOException JavaDoc;
10 import java.io.ObjectOutputStream JavaDoc;
11 import java.io.OutputStream JavaDoc;
12 import java.io.PrintWriter JavaDoc;
13 import java.sql.SQLException JavaDoc;
14 import javax.servlet.ServletException JavaDoc;
15 import javax.servlet.http.HttpServlet JavaDoc;
16 import javax.servlet.http.HttpServletRequest JavaDoc;
17 import javax.servlet.http.HttpServletResponse JavaDoc;
18 /**
19  *
20  * @author jindra
21  * @version
22  */

23 public class ComponentsServlet extends HttpServlet JavaDoc {
24     
25     /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
26      * @param request servlet request
27      * @param response servlet response
28      */

29     protected void processRequest(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
30     throws ServletException JavaDoc, IOException JavaDoc {
31         response.setContentType("text/html;charset=UTF-8");
32         PrintWriter JavaDoc out = response.getWriter();
33         /* TODO output your page here
34         out.println("<html>");
35         out.println("<head>");
36         out.println("<title>Servlet ComponentsServlet</title>");
37         out.println("</head>");
38         out.println("<body>");
39         out.println("<h1>Servlet ComponentsServlet at " + request.getContextPath () + "</h1>");
40         out.println("</body>");
41         out.println("</html>");
42          */

43         out.close();
44     }
45     
46     protected void doPut(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
47     throws ServletException JavaDoc, IOException JavaDoc {
48         try {
49             java.util.logging.Logger.getLogger(ComponentsServlet.class.getName()).log(java.util.logging.Level.INFO, "SENDING COMPONENTS");
50             OutputStream JavaDoc stream = response.getOutputStream();
51             ObjectOutputStream JavaDoc oStream = new ObjectOutputStream JavaDoc(stream);
52             oStream.writeObject(Utils.getComponents());
53             oStream.close();
54             stream.close();
55         } catch (SQLException JavaDoc ex) {
56             java.util.logging.Logger.getLogger(ComponentsServlet.class.getName()).log(java.util.logging.Level.SEVERE,
57                     ex.getMessage(), ex);
58         };
59         
60     }
61     
62     // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
63
/** Handles the HTTP <code>GET</code> method.
64      * @param request servlet request
65      * @param response servlet response
66      */

67     protected void doGet(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
68     throws ServletException JavaDoc, IOException JavaDoc {
69         processRequest(request, response);
70     }
71     
72     /** Handles the HTTP <code>POST</code> method.
73      * @param request servlet request
74      * @param response servlet response
75      */

76     protected void doPost(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
77     throws ServletException JavaDoc, IOException JavaDoc {
78         processRequest(request, response);
79     }
80     
81     /** Returns a short description of the servlet.
82      */

83     public String JavaDoc getServletInfo() {
84         return "Short description";
85     }
86     // </editor-fold>
87
}
88
Popular Tags