1 25 package org.ofbiz.webapp.taglib; 26 27 import java.io.IOException ; 28 import javax.servlet.ServletContext ; 29 import javax.servlet.http.HttpServletRequest ; 30 import javax.servlet.http.HttpServletResponse ; 31 import javax.servlet.jsp.JspException ; 32 import javax.servlet.jsp.tagext.BodyContent ; 33 import javax.servlet.jsp.tagext.BodyTagSupport ; 34 35 import org.ofbiz.base.util.Debug; 36 import org.ofbiz.base.util.UtilJ2eeCompat; 37 import org.ofbiz.webapp.control.RequestHandler; 38 39 46 public class UrlTag extends BodyTagSupport { 47 48 public static final String module = UrlTag.class.getName(); 49 50 public int doEndTag() throws JspException { 51 HttpServletRequest request = (HttpServletRequest ) pageContext.getRequest(); 52 HttpServletResponse response = (HttpServletResponse ) pageContext.getResponse(); 53 54 ServletContext context = (ServletContext ) request.getAttribute("servletContext"); 55 RequestHandler rh = (RequestHandler) context.getAttribute("_REQUEST_HANDLER_"); 56 57 BodyContent body = getBodyContent(); 58 59 String baseURL = body.getString(); 60 String newURL = rh.makeLink(request, response, baseURL); 61 62 body.clearBody(); 63 64 try { 65 getPreviousOut().print(newURL); 66 } catch (IOException e) { 67 if (UtilJ2eeCompat.useNestedJspException(pageContext.getServletContext())) { 68 throw new JspException (e.getMessage(), e); 69 } else { 70 Debug.logError(e, "Server does not support nested exceptions, here is the exception", module); 71 throw new JspException (e.toString()); 72 } 73 } 74 return SKIP_BODY; 75 } 76 } 77 | Popular Tags |