1 16 17 package org.apache.taglibs.standard.tag.common.fmt; 18 19 import java.util.TimeZone ; 20 21 import javax.servlet.jsp.JspException ; 22 import javax.servlet.jsp.PageContext ; 23 import javax.servlet.jsp.jstl.core.Config; 24 import javax.servlet.jsp.tagext.TagSupport ; 25 26 import org.apache.taglibs.standard.tag.common.core.Util; 27 28 34 35 public abstract class SetTimeZoneSupport extends TagSupport { 36 37 38 41 protected Object value; 43 44 47 private int scope; private String var; 50 51 54 public SetTimeZoneSupport() { 55 super(); 56 init(); 57 } 58 59 private void init() { 61 value = var = null; 62 scope = PageContext.PAGE_SCOPE; 63 } 64 65 66 69 public void setScope(String scope) { 70 this.scope = Util.getScope(scope); 71 } 72 73 public void setVar(String var) { 74 this.var = var; 75 } 76 77 78 81 public int doEndTag() throws JspException { 82 TimeZone timeZone = null; 83 84 if (value == null) { 85 timeZone = TimeZone.getTimeZone("GMT"); 86 } else if (value instanceof String ) { 87 if (((String ) value).trim().equals("")) { 88 timeZone = TimeZone.getTimeZone("GMT"); 89 } else { 90 timeZone = TimeZone.getTimeZone((String ) value); 91 } 92 } else { 93 timeZone = (TimeZone ) value; 94 } 95 96 if (var != null) { 97 pageContext.setAttribute(var, timeZone, scope); 98 } else { 99 Config.set(pageContext, Config.FMT_TIME_ZONE, timeZone, scope); 100 } 101 102 return EVAL_PAGE; 103 } 104 105 public void release() { 107 init(); 108 } 109 } 110 | Popular Tags |