1 17 package org.ajaxtags.servlets; 18 19 import java.io.IOException ; 20 import java.io.PrintWriter ; 21 22 import javax.servlet.ServletException ; 23 import javax.servlet.http.HttpServlet ; 24 import javax.servlet.http.HttpServletRequest ; 25 import javax.servlet.http.HttpServletResponse ; 26 27 28 37 public abstract class BaseAjaxServlet extends HttpServlet implements BaseAjaxXmlAction { 38 39 43 @Override 44 protected void doGet(HttpServletRequest request, HttpServletResponse response) 45 throws ServletException , IOException { 46 47 try { 48 String xml = null; 49 xml = AjaxActionHelper.invoke(this, request, response); 50 PrintWriter pw = response.getWriter(); 51 pw.write(xml); 52 pw.close(); 53 54 } catch (Exception ex) { 55 response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 57 "Can not create response"); 58 return; 59 } 60 } 61 62 66 @Override 67 protected void doPost(HttpServletRequest request, HttpServletResponse response) 68 throws ServletException , IOException { 69 doGet(request, response); 70 } 71 72 82 public abstract String getXmlContent(HttpServletRequest request, 83 HttpServletResponse response) throws Exception ; 84 } 85 | Popular Tags |