1 16 17 package org.apache.taglibs.standard.tag.common.fmt; 18 19 import java.io.UnsupportedEncodingException ; 20 21 import javax.servlet.jsp.JspException ; 22 import javax.servlet.jsp.JspTagException ; 23 import javax.servlet.jsp.PageContext ; 24 import javax.servlet.jsp.tagext.TagSupport ; 25 26 33 34 public abstract class RequestEncodingSupport extends TagSupport { 35 36 39 static final String REQUEST_CHAR_SET = 40 "javax.servlet.jsp.jstl.fmt.request.charset"; 41 42 43 46 private static final String DEFAULT_ENCODING = "ISO-8859-1"; 47 48 49 52 protected String value; 54 55 58 protected String charEncoding; 60 61 64 public RequestEncodingSupport() { 65 super(); 66 init(); 67 } 68 69 private void init() { 70 value = null; 71 } 72 73 74 77 public int doEndTag() throws JspException { 78 charEncoding = value; 79 if ((charEncoding == null) 80 && (pageContext.getRequest().getCharacterEncoding() == null)) { 81 charEncoding = (String ) 83 pageContext.getAttribute(REQUEST_CHAR_SET, 84 PageContext.SESSION_SCOPE); 85 if (charEncoding == null) { 86 charEncoding = DEFAULT_ENCODING; 88 } 89 } 90 91 95 if (charEncoding != null) { 96 try { 97 pageContext.getRequest().setCharacterEncoding(charEncoding); 98 } catch (UnsupportedEncodingException uee) { 99 throw new JspTagException (uee.toString(), uee); 100 } 101 } 102 103 return EVAL_PAGE; 104 } 105 106 public void release() { 108 init(); 109 } 110 } 111 | Popular Tags |