1 18 19 package org.apache.struts.tiles; 20 21 import java.io.IOException ; 22 23 import javax.servlet.RequestDispatcher ; 24 import javax.servlet.ServletContext ; 25 import javax.servlet.ServletException ; 26 import javax.servlet.http.HttpServletRequest ; 27 import javax.servlet.http.HttpServletResponse ; 28 29 32 public class UrlController implements Controller { 33 34 37 protected String url = null; 38 39 43 public UrlController(String url) { 44 this.url = url; 45 } 46 47 57 public void perform( 58 ComponentContext tileContext, 59 HttpServletRequest request, 60 HttpServletResponse response, 61 ServletContext servletContext) 62 throws ServletException , IOException { 63 64 RequestDispatcher rd = servletContext.getRequestDispatcher(url); 65 if (rd == null) { 66 throw new ServletException ( 67 "Controller can't find url '" + url + "'."); 68 } 69 70 rd.include(request, response); 71 } 72 73 76 public void execute( 77 ComponentContext tileContext, 78 HttpServletRequest request, 79 HttpServletResponse response, 80 ServletContext servletContext) 81 throws Exception { 82 83 RequestDispatcher rd = servletContext.getRequestDispatcher(url); 84 if (rd == null) { 85 throw new ServletException ( 86 "Controller can't find url '" + url + "'."); 87 } 88 89 rd.include(request, response); 90 91 } 92 93 } 94 | Popular Tags |