1 9 package org.jboss.portal.core.servlet.jsp.taglib; 10 11 import java.util.LinkedList ; 12 13 import javax.servlet.jsp.JspException ; 14 import javax.servlet.jsp.tagext.TagSupport ; 15 16 import org.jboss.portal.common.context.Context; 17 import org.jboss.portal.common.context.NamedContext; 18 import org.jboss.portal.core.servlet.jsp.PortalJsp; 19 20 25 public class IncludeTag 26 extends TagSupport 27 { 28 29 32 private String page; 33 34 37 private LinkedList formerContextStack; 38 39 private Context formerContext; 40 41 46 public void setPage(String filename) { 47 this.page = filename; 48 } 49 50 public int doStartTag() throws JspException { 51 52 formerContextStack = (LinkedList )PortalJsp.contextStack.get(); 54 formerContext = (Context)pageContext.getRequest().getAttribute(PortalJsp.CTX_REQUEST); 55 56 LinkedList list = (LinkedList )PortalJsp.contextStack.get(); 57 LinkedList stack = new LinkedList (); 58 if (!list.isEmpty()) { 59 NamedContext ctx = (NamedContext)(list).getLast(); 61 pageContext.getRequest().setAttribute(PortalJsp.CTX_REQUEST, ctx.getContext()); 62 63 stack.addLast(new NamedContext("", ctx.getContext())); 65 } 66 67 try 69 { 70 pageContext.include(page); 71 PortalJsp.contextStack.set(stack); 72 } catch (Exception e) { 73 PortalJsp.log.error("Cannot include page: " + page, e); 74 } finally { 75 PortalJsp.contextStack.set(formerContextStack); 77 pageContext.getRequest().setAttribute(PortalJsp.CTX_REQUEST, formerContext); 78 } 79 return SKIP_BODY; 80 } 81 82 } 83 | Popular Tags |