1 23 24 package org.dbforms.taglib; 25 26 import java.io.IOException ; 27 28 import javax.servlet.http.HttpServletRequest ; 29 import javax.servlet.jsp.JspException ; 30 import javax.servlet.jsp.JspWriter ; 31 32 33 34 44 public class BaseTag extends TagSupportWithScriptHandler { 45 52 public int doStartTag() throws JspException { 53 HttpServletRequest request = (HttpServletRequest ) pageContext.getRequest(); 54 StringBuffer buf = new StringBuffer ("<base HREF=\""); 55 buf.append(request.getScheme()); 56 buf.append("://"); 57 buf.append(request.getServerName()); 58 59 int port = request.getServerPort(); 60 61 if ((port != 80) && (port != 443)) { 62 buf.append(":"); 63 buf.append(String.valueOf(port)); 64 } 65 66 buf.append(request.getRequestURI()); 67 buf.append("\"/>"); 68 69 JspWriter out = pageContext.getOut(); 70 71 try { 72 out.write(buf.toString()); 73 } catch (IOException e) { 74 throw new JspException (e.toString()); 75 } 76 77 return EVAL_BODY_INCLUDE; 78 } 79 } 80 | Popular Tags |