1 5 package org.exoplatform.portlet.exomvc.config; 6 7 import java.io.InputStream ; 8 import javax.portlet.PortletContext; 9 import javax.portlet.PortletRequestDispatcher; 10 import javax.portlet.RenderRequest; 11 import javax.portlet.RenderResponse; 12 import org.exoplatform.commons.utils.IOUtil; 13 14 19 public class JSPResourceManager { 20 private String reposistoryPath_ ; 21 private PortletContext context_ ; 22 23 public JSPResourceManager(PortletContext context, String repo ) throws Exception { 24 reposistoryPath_ = repo + "/jsp/" ; 25 context_ = context ; 26 } 27 28 public String getJSPReposistory() { return reposistoryPath_ ; } 29 30 public void dispatch(String page, RenderRequest request, RenderResponse response) throws Exception { 31 PortletRequestDispatcher rd = context_.getRequestDispatcher(reposistoryPath_ + page) ; 32 rd.include(request, response); 33 } 34 35 public String getResourceAsText(String resource) throws Exception { 36 String path = reposistoryPath_ + resource ; 37 InputStream is = context_.getResourceAsStream(path) ; 38 if(is == null) return "reosurce : " + resource + " is notfound" ; 39 return IOUtil.getStreamContentAsString(is) ; 40 } 41 } | Popular Tags |