1 19 20 package za.org.coefficient.servlet; 21 22 import za.org.coefficient.util.common.HardURLConverterChainUtil; 23 24 import java.io.IOException ; 25 26 import javax.servlet.ServletException ; 27 import javax.servlet.http.HttpServlet ; 28 import javax.servlet.http.HttpServletRequest ; 29 import javax.servlet.http.HttpServletResponse ; 30 31 46 public class HardURLConverterServlet extends HttpServlet { 47 48 50 59 protected void doGet(HttpServletRequest request, 60 HttpServletResponse response) throws ServletException , IOException { 61 String pathInfo = request.getPathInfo(); 62 String servletPath = request.getServletPath(); 63 String contextPath = request.getContextPath(); 64 String path = 65 (pathInfo == null) ? contextPath + "/" + servletPath : (contextPath+ "/" + servletPath + "/" + pathInfo); 66 67 String redirectURL = HardURLConverterChainUtil.execute(path); 68 if(redirectURL != null) { 69 response.sendRedirect(redirectURL); 70 } else { 71 response.sendRedirect(contextPath + "/index.html?module=Error&errorMsg=The%20URL " 72 + path + "%20is%20not%20recognized%20by%20the%20system"); 73 } 74 } 75 76 82 protected void doPost(HttpServletRequest request, 83 HttpServletResponse response) throws ServletException , IOException { 84 doGet(request, response); 85 } 86 87 } 88 | Popular Tags |