Ext.Ajax.request({url:'DeleteAction',success: doneFunction,failure: errorFunction,params:{name:rname}});
The above code is my Ajax request which goes to DeleteAction Servelet. Can anyone let me know what happens next in the below code.
- When this file is called what is first thing getting called.
- What does the doGet and doPost method do?
- How does it identify the doProcess method in this?
- Is it neccessary to have a constructor.
How is the response sent back to Ajax.
public class DeleteAction extends HttpServlet implements Servlet { public DeleteAction() { super(); } protected void process(HttpServletRequest request, HttpServletResponse response) {
} protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { process(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { process(request, response); } }try { ServletOutputStream sos = response.getOutputStream(); response.setHeader("Cache-Control", "no-store"); response.setHeader("Pragma", "no-cache"); response.setContentType("text/plain"); String name = request.getParameter("name"); System.out.println("Name: " + name); String query = "DELETE from CRUD_DATA where name='" + name + "'"; System.out.println("Query:" + query); OracleDataSource ods = new OracleDataSource(); ods.setUser("abdel"); ods.setPassword("password"); ods.setURL("jdbc:oracle:thin:@//127.0.0.1/XE"); Connection conn = ods.getConnection(); Statement statement = conn.createStatement(); statement.executeUpdate(query); conn.commit(); conn.close(); sos.print("{success:true}"); sos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }