1 16 17 package org.apache.taglibs.response; 18 19 import java.util.*; 20 import javax.servlet.*; 21 import javax.servlet.http.*; 22 import javax.servlet.jsp.*; 23 import javax.servlet.jsp.tagext.*; 24 25 42 43 public class EncodeURLTag extends BodyTagSupport 44 { 45 private String encoded_url = null; 46 47 52 public final int doStartTag() throws JspException 53 { 54 return EVAL_BODY_TAG; 55 } 56 57 63 public final int doAfterBody() throws JspException 64 { 65 BodyContent body = getBodyContent(); 67 String s = body.getString().trim(); 68 body.clearBody(); 71 72 encoded_url = 73 ((HttpServletResponse)pageContext.getResponse()).encodeURL(s); 74 75 return SKIP_BODY; 76 } 77 78 83 public final int doEndTag() throws JspException 84 { 85 try { 86 pageContext.getOut().write(encoded_url); 87 } catch(Exception e) { 88 throw new JspException("IO Error: " + e.getMessage()); 89 } 90 return EVAL_PAGE; 91 } 92 93 } 94 | Popular Tags |