1 61 62 63 package org.nemesis.forum.webapp.admin.tag; 64 65 66 import javax.servlet.http.HttpSession ; 67 import javax.servlet.jsp.JspException ; 68 import javax.servlet.jsp.tagext.TagSupport ; 69 70 import org.apache.struts.config.ModuleConfig; 71 import org.nemesis.forum.webapp.admin.Constants; 72 73 74 82 83 public final class CheckLogonTag extends TagSupport { 84 85 86 88 89 92 private String name = Constants.USER_KEY; 93 94 95 98 private String page = "/frameset.do"; 99 100 101 103 104 107 public String getName() { 108 109 return (this.name); 110 111 } 112 113 114 119 public void setName(String name) { 120 121 this.name = name; 122 123 } 124 125 126 129 public String getPage() { 130 131 return (this.page); 132 133 } 134 135 136 141 public void setPage(String page) { 142 143 this.page = page; 144 145 } 146 147 148 150 151 156 public int doStartTag() throws JspException { 157 158 return (SKIP_BODY); 159 160 } 161 162 163 170 public int doEndTag() throws JspException { 171 172 boolean valid = false; 174 175 HttpSession session = pageContext.getSession(); 176 if ((session != null) && (session.getAttribute(name) != null)) 177 valid = true; 178 179 if (valid) 181 return (EVAL_PAGE); 182 else { 183 ModuleConfig config = (ModuleConfig) pageContext.getRequest() 184 .getAttribute(org.apache.struts.Globals.MODULE_KEY); 185 try { 186 187 pageContext.forward( page); 188 } catch (Exception e) { 189 e.printStackTrace(); 190 throw new JspException (e.toString()); 191 } 192 return (SKIP_PAGE); 193 } 194 195 } 196 197 198 201 public void release() { 202 203 super.release(); 204 this.name = Constants.USER_KEY; 205 this.page = "/frameset.do"; 206 207 } 208 209 210 } 211 | Popular Tags |