1 28 29 package com.caucho.jstl.rt; 30 31 import com.caucho.jstl.NameValueTag; 32 import com.caucho.util.CharBuffer; 33 import com.caucho.util.L10N; 34 35 import javax.servlet.http.HttpServletResponse ; 36 import javax.servlet.jsp.JspException ; 37 import javax.servlet.jsp.tagext.TagSupport ; 38 import java.io.IOException ; 39 40 public class CoreRedirectTag extends TagSupport implements NameValueTag { 41 private static L10N L = new L10N(CoreRedirectTag.class); 42 43 private String _value; 44 private String _context; 45 46 private CharBuffer _url; 47 48 51 public void setURL(String value) 52 { 53 _value = value; 54 } 55 56 59 public void setContext(String context) 60 { 61 _context = context; 62 } 63 64 67 public void addParam(String name, String value) 68 { 69 String encoding = this.pageContext.getResponse().getCharacterEncoding(); 70 71 CoreUrlTag.addParam(_url, name, value, encoding); 72 } 73 74 public int doStartTag() throws JspException 75 { 76 _url = CoreUrlTag.normalizeURL(pageContext, _value, _context); 77 78 return EVAL_BODY_INCLUDE; 79 } 80 81 public int doEndTag() throws JspException 82 { 83 String value = CoreUrlTag.encodeURL(pageContext, _url); 84 85 try { 86 HttpServletResponse response; 87 ((HttpServletResponse ) pageContext.getResponse()).sendRedirect(value); 88 } catch (IOException e) { 89 throw new JspException (e); 90 } 91 92 return SKIP_PAGE; 93 } 94 } 95 | Popular Tags |