1 16 17 package org.apache.taglibs.response; 18 19 import java.io.*; 20 import java.lang.*; 21 import java.lang.reflect.*; 22 import java.util.*; 23 import javax.servlet.*; 24 import javax.servlet.http.*; 25 import javax.servlet.jsp.*; 26 import javax.servlet.jsp.tagext.*; 27 28 46 47 public class SetStatusTag extends TagSupport 48 { 49 private String status; 50 51 56 public final int doEndTag() throws JspException 57 { 58 int status_code = 0; 59 HttpServletResponse resp = null; 60 Field ec = null; 61 62 try { 63 resp = (HttpServletResponse)pageContext.getResponse(); 64 Class rc = resp.getClass(); 65 ec = rc.getField(status); 66 status_code = ec.getInt(resp); 67 } catch(Exception e) { 68 throw new JspException( 69 "Response setStatus tag could not find status code: " + status); 70 } 71 72 ((HttpServletResponse)pageContext.getResponse()).setStatus(status_code); 73 return EVAL_PAGE; 74 } 75 76 85 public final void setStatus(String stat) 86 { 87 status = stat; 88 } 89 } 90 | Popular Tags |