1 16 17 package org.apache.taglibs.standard.tag.common.core; 18 19 import javax.servlet.http.HttpServletResponse ; 20 import javax.servlet.jsp.JspException ; 21 import javax.servlet.jsp.JspTagException ; 22 import javax.servlet.jsp.PageContext ; 23 import javax.servlet.jsp.tagext.BodyTagSupport ; 24 25 31 32 public abstract class RedirectSupport extends BodyTagSupport 33 implements ParamParent { 34 35 38 protected String url; protected String context; 41 44 private String var; private int scope; private ParamSupport.ParamManager params; 48 51 public RedirectSupport() { 52 super(); 53 init(); 54 } 55 56 private void init() { 57 url = var = null; 58 params = null; 59 scope = PageContext.PAGE_SCOPE; 60 } 61 62 63 66 public void setVar(String var) { 67 this.var = var; 68 } 69 70 public void setScope(String scope) { 71 this.scope = Util.getScope(scope); 72 } 73 74 75 78 public void addParameter(String name, String value) { 80 params.addParameter(name, value); 81 } 82 83 84 87 public int doStartTag() throws JspException { 89 params = new ParamSupport.ParamManager(); 90 return EVAL_BODY_BUFFERED; 91 } 92 93 94 public int doEndTag() throws JspException { 96 String result; 98 String baseUrl = UrlSupport.resolveUrl(url, context, pageContext); 100 result = params.aggregateParams(baseUrl); 101 102 HttpServletResponse response = 104 ((HttpServletResponse ) pageContext.getResponse()); 105 if (!ImportSupport.isAbsoluteUrl(result)) 106 result = response.encodeRedirectURL(result); 107 108 try { 110 response.sendRedirect(result); 111 } catch (java.io.IOException ex) { 112 throw new JspTagException (ex.toString(), ex); 113 } 114 115 return SKIP_PAGE; 116 } 117 118 public void release() { 120 init(); 121 } 122 } 123 | Popular Tags |