1 16 17 package org.apache.taglibs.response; 18 19 import java.io.*; 20 import java.util.*; 21 import javax.servlet.*; 22 import javax.servlet.http.*; 23 import javax.servlet.jsp.*; 24 import javax.servlet.jsp.tagext.*; 25 26 43 44 public class SendRedirectTag extends BodyTagSupport 45 { 46 47 52 public final int doStartTag() throws JspException 53 { 54 return EVAL_BODY_TAG; 55 } 56 57 62 public final int doAfterBody() throws JspException 63 { 64 BodyContent body = getBodyContent(); 66 String s = body.getString().trim(); 67 body.clearBody(); 70 71 try { 72 ((HttpServletResponse)pageContext.getResponse()).sendRedirect(s); 73 } catch(IOException e) { 74 throw new JspException( 75 "Response sendRedirect tag could not return the redirect: " + 76 e.getMessage()); 77 } catch(IllegalStateException e) { 78 throw new JspException( 79 "Response sendRedirect tag could not return the redirect: " + 80 e.getMessage()); 81 } 82 83 return SKIP_BODY; 84 } 85 86 92 public final int doEndTag() throws JspException 93 { 94 return SKIP_PAGE; 95 } 96 97 } 98 | Popular Tags |