001 package com.khubla.pragmatach.plugin.jsp; 002 003 import java.util.Map; 004 005 import javax.servlet.http.HttpServlet; 006 import javax.servlet.http.HttpServletRequest; 007 import javax.servlet.http.HttpServletResponse; 008 009 import com.khubla.pragmatach.framework.api.PragmatachException; 010 import com.khubla.pragmatach.framework.controller.impl.AbstractResponse; 011 012 /** 013 * @author tome 014 */ 015 public class JSPResponse extends AbstractResponse { 016 /** 017 * httpServlet 018 */ 019 private final HttpServlet httpServlet; 020 /** 021 * request 022 */ 023 private final HttpServletRequest httpServletRequest; 024 025 public JSPResponse(Map<String, String> cacheHeaders, HttpServlet httpServlet, HttpServletRequest httpServletRequest) { 026 super(cacheHeaders); 027 this.httpServlet = httpServlet; 028 this.httpServletRequest = httpServletRequest; 029 } 030 031 @Override 032 public String getContentType() throws PragmatachException { 033 return CONTENT_TYPE_HTML; 034 } 035 036 @Override 037 public Map<String, String> getHeaders() throws PragmatachException { 038 return super.getCacheHeaders(); 039 } 040 041 @Override 042 public void render(HttpServletResponse httpServletResponse) throws PragmatachException { 043 try { 044 httpServlet.service(httpServletRequest, httpServletResponse); 045 } catch (final Exception e) { 046 throw new PragmatachException("Exception in render", e); 047 } 048 } 049 }