package mytag;

import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTagSupport;

public class OutTag extends BodyTagSupport
{
    private boolean print;

    public boolean isPrint()
    {
        return print;
    }

    public void setPrint(boolean print)
    {
        this.print = print;
    }

    private String content;

    public String getContent()
    {
        return content;
    }

    public void setContent(String content)
    {
        this.content = content;
    }

    private PageContext context;

    public void setPageContext(PageContext arg0)
    {
        this.context=arg0;

    }

    public int doStartTag()throws JspTagException
    {
        if(print)
        {
            return EVAL_BODY_BUFFERED;
        }
        else
        {
            return SKIP_BODY;
        }
    }
    public int doEndTag()throws JspTagException
    {
       try
       {
          if(bodyContent!=null)
          {
              bodyContent.writeOut(bodyContent.getEnclosingWriter());
          }

       }
       catch(Exception e)
       {
           throw new  JspTagException(e.getMessage());
       }
       release();
       return EVAL_PAGE;
    }
}
