jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From morg...@apache.org
Subject cvs commit: jakarta-taglibs/scopes/src/org/apache/taglibs/scopes AttributesTag.java AttributesTEI.java AttributeTag.java BaseScopedBodyTag.java BaseScopedTag.java EqualsAttributeTag.java EqualsInitParameterTag.java ExistsAttributeTag.java ExistsInitParameterTag.java InitParametersTag.java InitParametersTEI.java InitParameterTag.java RemoveAttributeTag.java SetAttributeTag.java
Date Tue, 06 Mar 2001 23:07:58 GMT
morgand     01/03/06 15:07:58

  Added:       scopes/src/org/apache/taglibs/scopes AttributesTag.java
                        AttributesTEI.java AttributeTag.java
                        BaseScopedBodyTag.java BaseScopedTag.java
                        EqualsAttributeTag.java EqualsInitParameterTag.java
                        ExistsAttributeTag.java ExistsInitParameterTag.java
                        InitParametersTag.java InitParametersTEI.java
                        InitParameterTag.java RemoveAttributeTag.java
                        SetAttributeTag.java
  Log:
  new provisional taglib "scopes"
  
  Revision  Changes    Path
  1.1                  jakarta-taglibs/scopes/src/org/apache/taglibs/scopes/AttributesTag.java
  
  Index: AttributesTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The _names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their _names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.taglibs.scopes;
  
  import java.util.Enumeration;
  
  import javax.servlet.ServletContext;
  
  import javax.servlet.jsp.JspException;
  import javax.servlet.jsp.PageContext;
  
  
  /**
   * JSP Tag <b>_attributes</b>, used to get ServletContext _attribute
   * information using the standard JSP 1.2 &lt;jsp:getProperty&gt; tag.
   * <p>
   * The script variable of _name <b>id</b> is availble only within the
   * body of the <b>_attributes</b> tag.
   * <p>
   * Loops through all the _attributes in the ServletContext.
   * <p>
   * JSP Tag Lib Descriptor
   * <p><pre>
   * &lt;_name&gt;_attributes&lt;/_name&gt;
   * &lt;tagclass&gt;org.apache.taglibs.application.AttributesTag&lt;/tagclass&gt;
   * &lt;teiclass&gt;org.apache.taglibs.application.AttributesTEI&lt;/teiclass&gt;
   * &lt;bodycontent&gt;JSP&lt;/bodycontent&gt;
   * &lt;info&gt;Loop through all _attributes or get a single _attribute.&lt;/info&gt;
   *   &lt;_attribute&gt;
   *     &lt;_name&gt;id&lt;/_name&gt;
   *     &lt;required&gt;true&lt;/required&gt;
   *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
   *   &lt;/_attribute&gt;
   * </pre>
   *
   * @author Morgan Delagrange
   */
  
  public class AttributesTag extends BaseScopedBodyTag
  {
      private String _name = null;
      private ServletContext _app = null;
      private Enumeration _attributes = null;
      private String _attribute = null;
  
      /**
       * Loops through all the _attributes that came within the ServletContext.
       *
       * @return SKIP_BODY if no _attributes are found, EVAL_BODY_TAG if an _attribute exists
       */
      public final int doStartTag() throws JspException
      {
  
  	_attributes = pageContext.getAttributeNamesInScope(_scope);
  	if( _attributes == null || !_attributes.hasMoreElements() )
  	    return SKIP_BODY;
  	_attribute = (String)_attributes.nextElement();
  	if( _attribute == null )
  	    return SKIP_BODY;
  
  	pageContext.setAttribute(id,this,_scope);
  	return EVAL_BODY_TAG;
      }
  
      /**
       * Method called at end of each _attributes tag.
       *
       * @return EVAL_BODY_TAG if there is another _attribute, or SKIP_BODY if there are no more _attributes
       */
      public final int doAfterBody() throws JspException
      {
  	// See if this is the last _attribute
  	if( !_attributes.hasMoreElements() )
  	    return SKIP_BODY;
  	// There is another _attribute, so loop again
  	_attribute = (String)_attributes.nextElement();
  	if( _attribute == null )
  	    return SKIP_BODY;
  	return EVAL_BODY_TAG;
      }
  
      /**
       * Method called at end of Tag
       * @return EVAL_PAGE
       */
      public final int doEndTag() throws JspException
      {
  	try
  	{
  	    if(bodyContent != null)
  	    bodyContent.writeOut(bodyContent.getEnclosingWriter());
  	} catch(java.io.IOException e)
  	{
  	    throw new JspException("IO Error: " + e.getMessage());
  	}
  	return EVAL_PAGE;
      }
  
      /**
       * Returns the _name of the _attribute.
       * <p>
       * &lt;jsp:getProperty _name=<i>"id"</i> property="_name"/&gt;
       *
       * @return String - _attribute _name
       */
      public final String getName()
      {
  	return _attribute;
      }
  
      /**
       * Returns the value of the _attribute.
       * <p>
       * &lt;jsp:getProperty _name=<i>"id"</i> property="_attribute"/&gt;
       *
       * @return String - value of the _attribute
       */
      public final String getAttribute()
      {
  	Object value = _app.getAttribute(_attribute);
  	if( value == null )
  	    return "";
  	return "" + value.toString();
      }
  
      /**
       * Remove the script variable after _attributes tag closed out
       */
      public final void release()
      {
  	if( id != null && id.length() > 0 )
  	    pageContext.removeAttribute(id,_scope);
      }
  }
  
  
  
  1.1                  jakarta-taglibs/scopes/src/org/apache/taglibs/scopes/AttributesTEI.java
  
  Index: AttributesTEI.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.taglibs.scopes;
  
  import javax.servlet.jsp.tagext.TagData;
  import javax.servlet.jsp.tagext.TagExtraInfo;
  import javax.servlet.jsp.tagext.VariableInfo;
  
  /**
   * TagExtraInfo for <b>attributes</b> tag, allows use of standard
   * JSP 1.2 &lt;jsp:getProperty/&gt; with the <b>attributes</b> tag script
   * variable id.
   *
   * @see AttributesTag
   *
   * @author Morgan Delagrange
   */
  
  public class AttributesTEI extends TagExtraInfo
  {
  
      public final VariableInfo[] getVariableInfo(TagData data)
      {
  	return new VariableInfo[]
  	{
  	    new VariableInfo(
  		data.getAttributeString("id"),
  		"org.apache.taglibs.scopes.AttributesTag",
  		true,
  		VariableInfo.NESTED
  	    ),
  	};
      }
  }
  
  
  
  1.1                  jakarta-taglibs/scopes/src/org/apache/taglibs/scopes/AttributeTag.java
  
  Index: AttributeTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.taglibs.scopes;
  
  import java.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import javax.servlet.jsp.*;
  
  /**
   * JSP Tag <b>attribute</b>, used to output the value for a single
   * ServletContext attribute named with <b>_name</b>.
   * <p>
   * JSP Tag Lib Descriptor
   * <p><pre>
   * &lt;_name&gt;attribute&lt;/_name&gt;
   * &lt;tagclass&gt;org.apache.taglibs.application.AttributeTag&lt;/tagclass&gt;
   * &lt;bodycontent&gt;empty&lt;/bodycontent&gt;
   * &lt;info&gt;Output the value of a single attribute.&lt;/info&gt;
   *   &lt;attribute&gt;
   *     &lt;_name&gt;_name&lt;/_name&gt;
   *     &lt;required&gt;true&lt;/required&gt;
   *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
   *   &lt;/attribute&gt;
   * </pre>
   *
   * @author Morgan Delagrange
   */
  
  public class AttributeTag extends BaseScopedTag
  {
      // Name of application attribute
      private String _name = null;
  
      /**
       * Method called at end of Tag to output attribute value
       *
       * @return EVAL_PAGE
       */
      public final int doEndTag() throws JspException
      {
  	Object value =
  	    pageContext.getAttribute(_name,_scope);
  	if( value == null )
  	    value = "";
  
  	try {
  	    pageContext.getOut().write(value.toString());
  	} catch(Exception e) {
  	    throw new JspException("IO Error: " + e.getMessage());
  	}
  
  	return EVAL_PAGE;
      }
  
      /**
       * Set the required tag attribute <b>_name</b>. 
       *
       * @param String _name of application attribute
       */
      public final void setName(String str)
      {
  	_name = str;
      }
  
  }
  
  
  
  1.1                  jakarta-taglibs/scopes/src/org/apache/taglibs/scopes/BaseScopedBodyTag.java
  
  Index: BaseScopedBodyTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The _names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their _names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.taglibs.scopes;
  
  import javax.servlet.jsp.tagext.BodyTagSupport;
  import javax.servlet.jsp.PageContext;
  
  public class BaseScopedBodyTag extends BodyTagSupport {
        
    protected int _scope = PageContext.PAGE_SCOPE;
  
    public void setScope(String scopeName) {
      if (scopeName.equals("request")) {
        _scope = PageContext.REQUEST_SCOPE;
      } else if (scopeName.equals("session")) {
        _scope = PageContext.SESSION_SCOPE;
      } else if (scopeName.equals("application")) {
        _scope = PageContext.APPLICATION_SCOPE;
      }
    }
  }
  
  
  
  1.1                  jakarta-taglibs/scopes/src/org/apache/taglibs/scopes/BaseScopedTag.java
  
  Index: BaseScopedTag.java
  ===================================================================
  
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The _names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their _names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.taglibs.scopes;
  
  import javax.servlet.jsp.tagext.TagSupport;
  import javax.servlet.jsp.PageContext;
  
  public class BaseScopedTag extends TagSupport {
        
    protected int _scope = PageContext.PAGE_SCOPE;
  
    public void setScope(String scopeName) {
      if (scopeName.equals("request")) {
        _scope = PageContext.REQUEST_SCOPE;
      } else if (scopeName.equals("session")) {
        _scope = PageContext.SESSION_SCOPE;
      } else if (scopeName.equals("application")) {
        _scope = PageContext.APPLICATION_SCOPE;
      }
    }
  }
  
  
  
  1.1                  jakarta-taglibs/scopes/src/org/apache/taglibs/scopes/EqualsAttributeTag.java
  
  Index: EqualsAttributeTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.taglibs.scopes;
  
  import java.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  
  /**
   * JSP Tag <b>equalsattribute</b>, used to determine if a ServletContext
   * attribute equals the _value of the "_match" tag attribute.
   * <p>
   * Includes the body of the tag if the attribute equals the _value of the 
   * "_match" tag attribute.
   * <p>
   * You can set the optional tag attribute <b>_value</b> to <i>true</i> or
   * <i>false</i>.  The body of the tag is included if equalsattribute matches
   * the _value.
   * <p>
   * You can set the optional tag attribute <b>_ignorecase</b> to <i>true</i> or
   * <i>false</i>.  If _ignorecase is set to true, then the comparison between the
   * application attribute and the "_match" tag attribute will <i>not</i> be 
   * case-sensitive.
   * <p>
   * JSP Tag Lib Descriptor
   * <p><pre>
   * &lt;_name>equalsattribute&lt;/_name>
   * &lt;tagclass>org.apache.taglibs.application.EqualsAttributeTag&lt;/tagclass>
   * &lt;bodycontent>JSP&lt;/bodycontent>
   * &lt;info>Includes the body of the tag if the application attribute equals the
   * _value of the "_match" tag attribute.&lt;/info>
   *   &lt;attribute>
   *     &lt;_name>_name&lt;/_name>
   *     &lt;required>true&lt;/required>
   *     &lt;rtexprvalue>false&lt;/rtexprvalue>
   *   &lt;/attribute>
   *   &lt;attribute>
   *     &lt;_name>_value&lt;/_name>
   *     &lt;required>false&lt;/required>
   *     &lt;rtexprvalue>false&lt;/rtexprvalue>
   *   &lt;/attribute>
   *   &lt;attribute>
   *     &lt;_name>_match&lt;/_name>
   *     &lt;required>true&lt;/required>
   *     &lt;rtexprvalue>true&lt;/rtexprvalue>
   *   &lt;/attribute>
   *   &lt;attribute>
   *     &lt;_name>_ignorecase&lt;/_name>
   *     &lt;required>false&lt;/required>
   *     &lt;rtexprvalue>false&lt;/rtexprvalue>
   *   &lt;/attribute>
   * </pre>
   *
   * @author Morgan Delagrange
   */
  
  public class EqualsAttributeTag extends BaseScopedTag
  {
      private String _name = null;
      private String _match = null;
      //default behaviour is don't ignore case and execute body when tag contents
      //equal _value set by setMatch
      private Boolean _ignorecase = new Boolean("false");
      private Boolean _value = new Boolean("true");
  
      /**
       * Includes the body of the tag if the application attribute equals the _value set in the 
       * '_match' attribute.
       *
       * @return SKIP_BODY if equalsattribute body content does not equal the _value of 
       * the _match attribute, EVAL_BODY_include if it does
       */
      public final int doStartTag() throws JspException
      {
        //result is whether or not tag contents equal the _match attribute
  	    boolean result = false;
        Object attribute = pageContext.getAttribute(_name,_scope);
        
        if (attribute == null) {
          result = false;
        } else {
          String attributeValue = attribute.toString();
          
  	      if (_ignorecase.booleanValue() == true) {
            result = attributeValue.equalsIgnoreCase(_match);
          } else {
            result = attributeValue.equals(_match);
          }
        }
        
        if (result == true) {
          if (_value.booleanValue() == true) {
            return EVAL_BODY_INCLUDE;
          } else {
            return SKIP_BODY;
          }
        } else {
          if (_value.booleanValue() == false) {
            return EVAL_BODY_INCLUDE;
          } else {
            return SKIP_BODY;
          }
        }
  
      }
  
      /**
       * Set the required tag attribute <b>_name</b>. 
       *
       * @param String _name of application attribute
       */
      public final void setName(String str)
      {   
  	_name = str;
      }
  
      /**
       * Set the String that will be compared to the application
       * attribute.
       *
       * @param String _value to _match against the application attribute
       */
      public final void setMatch(String str) {
        _match=str;
      }
      
      /**
       * If _ignorecase is set to true, then the comparison 
       * between the "_match" attribute and the 
       * application attribute will <i>not</i> be case sensitive
       * 
       * @param str    true = ignore case<BR>false = case sensitive<BR>
       *               default _value = false
       */
      public final void setIgnorecase(String str) {
        _ignorecase = new Boolean(str);
      }
      
      /**
       * Set the optional tag attribute <b>_value</b> to true or false. 
       *
       * @param String true or false
       */
      public final void setValue(String str)
      {
  	_value = new Boolean(str);
      }
  
      public void release() {
        _name = null;
        _match = null;
        //default behaviour is don't ignore case and execute body when tag contents
        //equal _value set by setMatch
        _ignorecase = new Boolean("false");
        _value = new Boolean("true"); 
      }
  }
  
  
  
  1.1                  jakarta-taglibs/scopes/src/org/apache/taglibs/scopes/EqualsInitParameterTag.java
  
  Index: EqualsInitParameterTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.taglibs.scopes;
  
  import java.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  
  /**
   * JSP Tag <b>equalsinitparameter</b>, used to determine if an init parameter
   * equals the _value of the "_match" tag attribute.
   * <p>
   * Includes the body of the tag if the init parameter equals the _value of the 
   * "_match" tag attribute.
   * <p>
   * You can set the optional tag attribute <b>_value</b> to <i>true</i> or
   * <i>false</i>.  The body of the tag is included if equalsinitparameter matches
   * the _value.
   * <p>
   * You can set the optional tag attribute <b>_ignorecase</b> to <i>true</i> or
   * <i>false</i>.  If _ignorecase is set to true, then the comparison between the
   * init parameter and the "_match" tag attribute will <i>not</i> be 
   * case-sensitive.
   * <p>
   * JSP Tag Lib Descriptor
   * <p><pre>
   * &lt;_name>equalsinitparameter&lt;/_name>;
   * &lt;tagclass>org.apache.taglibs.application.EqualsInitParamaeterTag&lt;/tagclass>
   * &lt;bodycontent>JSP&lt;/bodycontent>
   * &lt;info>Includes the body of the tag if the init parameter equals the
   * _value of the "_match" tag attribute.&lt;/info>
   *   &lt;attribute>
   *     &lt;_name>_name&lt;/_name>
   *     &lt;required>true&lt;/required>
   *     &lt;rtexprvalue>false&lt;/rtexprvalue>
   *   &lt;/attribute>
   *   &lt;attribute>
   *     &lt;_name>_value&lt;/_name>
   *     &lt;required>false&lt;/required>
   *     &lt;rtexprvalue>false&lt;/rtexprvalue>
   *   &lt;/attribute>
   *   &lt;attribute>
   *     &lt;_name>_match&lt;/_name>
   *     &lt;required>true&lt;/required>
   *     &lt;rtexprvalue>true&lt;/rtexprvalue>
   *   &lt;/attribute>
   *   &lt;attribute>
   *     &lt;_name>_ignorecase&lt;/_name>
   *     &lt;required>false&lt;/required>
   *     &lt;rtexprvalue>false&lt;/rtexprvalue>
   *   &lt;/attribute>
   * </pre>
   *
   * @author Morgan Delagrange
   */
  
  public class EqualsInitParameterTag extends TagSupport
  {
      private String _name = null;
      private String _match = null;
      //default behaviour is don't ignore case and execute body when tag contents
      //equal _value set by setMatch
      private Boolean _ignorecase = new Boolean("false");
      private Boolean _value = new Boolean("true");
  
      /**
       * Includes the body of the tag if the init parameter equals the _value set in the 
       * '_match' attribute.
       *
       * @return SKIP_BODY if equalsinitparameter doesn't _match _value, EVAL_BODY_include if equalsinitparameter matches _value
       */
      public final int doStartTag() throws JspException
      {
        //result is whether or not tag contents equal the _match attribute
  	    boolean result = false;
        String initParam = pageContext.getServletContext().getInitParameter(_name);
        
        if (initParam == null) {
          result = false;
        } else {
  	      if (_ignorecase.booleanValue() == true) {
            result = initParam.equalsIgnoreCase(_match);
          } else {
            result = initParam.equals(_match);
          }
        }
        
        if (result == true) {
          if (_value.booleanValue() == true) {
            return EVAL_BODY_INCLUDE;
          } else {
            return SKIP_BODY;
          }
        } else {
          if (_value.booleanValue() == false) {
            return EVAL_BODY_INCLUDE;
          } else {
            return SKIP_BODY;
          }
        }
  
      }
  
      /**
       * Set the required tag attribute <b>_name</b>. 
       *
       * @param String _name of init parameter
       */
      public final void setName(String str)
      {   
  	_name = str;
      }
  
      /**
       * Set the String that will be compared to the init
       * parameter.
       *
       * @param String _value to _match against the init parameter
       */
      public final void setMatch(String str) {
        _match=str;
      }
      
      /**
       * If _ignorecase is set to true, then the comparison 
       * between the "_match" attribute and the 
       * init parameter will <i>not</i> be case sensitive
       * 
       * @param str    true = ignore case<BR>false = case sensitive<BR>
       *               default _value = false
       */
      public final void setIgnorecase(String str) {
        _ignorecase = new Boolean(str);
      }
      
      /**
       * Set the optional tag attribute <b>_value</b> to true or false. 
       *
       * @param String true or false
       */
      public final void setValue(String str)
      {
  	_value = new Boolean(str);
      }
  
      public void release() {
        _name = null;
        _match = null;
        //default behaviour is don't ignore case and execute body when tag contents
        //equal _value set by setMatch
        _ignorecase = new Boolean("false");
        _value = new Boolean("true"); 
      }
  }
  
  
  
  1.1                  jakarta-taglibs/scopes/src/org/apache/taglibs/scopes/ExistsAttributeTag.java
  
  Index: ExistsAttributeTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.taglibs.scopes;
  
  import java.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  
  /**
   * JSP Tag <b>existsattribute</b>, used to determine if a ServletContext
   * attribute exists.
   * <p>
   * Includes the body of the tag if the attribute exists.
   * <p>
   * You can set the optional tag attribute <b>_value</b> to <i>true</i> or
   * <i>false</i>.  The body of the tag is included if existsattribute matches
   * the _value.
   * <p>
   * JSP Tag Lib Descriptor
   * <p><pre>
   * &lt;_name&gt;existsattribute&lt;/_name&gt;
   * &lt;tagclass&gt;org.apache.taglibs.application.ExistsAttributeTag&lt;/tagclass&gt;
   * &lt;bodycontent&gt;JSP&lt;/bodycontent&gt;
   * &lt;info&gt;Includes the body of the tag if the application attribute exists.&lt;/info&gt;
   *   &lt;attribute&gt;
   *     &lt;_name&gt;_name&lt;/_name&gt;
   *     &lt;required&gt;true&lt;/required&gt;
   *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
   *   &lt;/attribute&gt;
   *   &lt;attribute&gt;
   *     &lt;_name&gt;_value&lt;/_name&gt;
   *     &lt;required&gt;false&lt;/required&gt;
   *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
   *   &lt;/attribute&gt;
   * </pre>
   *
   * @author Morgan Delagrange
   */
  
  public class ExistsAttributeTag extends BaseScopedTag
  {
      private String _name = null;
      private Boolean _value = null;
  
      /**
       * Includes the body of the tag if the application attribute exists.
       *
       * @return SKIP_BODY if existsattribute doesn't match _value, EVAL_BODY_include if existsattribute matches _value
       */
      public final int doStartTag() throws JspException
      {
  	boolean result = false;
  	if( pageContext.getAttribute(_name,_scope) != null )
  	    result = true;
  
  	if( _value == null ) {
  	   if( result )
  		return EVAL_BODY_INCLUDE;
  	   return SKIP_BODY;
  	}
  	if( _value.booleanValue() == result )
  	    return EVAL_BODY_INCLUDE;
  	return SKIP_BODY;
      }
  
      /**
       * Set the required tag attribute <b>_name</b>. 
       *
       * @param String _name of application attribute
       */
      public final void setName(String str)
      {   
  	_name = str;
      }
  
      /**
       * Set the optional tag attribute <b>_value</b> to true or false. 
       *
       * @param String true or false
       */
      public final void setValue(String str)
      {
  	_value = new Boolean(str);
      }
  
  }
  
  
  
  1.1                  jakarta-taglibs/scopes/src/org/apache/taglibs/scopes/ExistsInitParameterTag.java
  
  Index: ExistsInitParameterTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.taglibs.scopes;
  
  import java.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  
  /**
   * JSP Tag <b>existsattribute</b>, used to determine if an init parameter
   * exists.
   * <p>
   * Includes the body of the tag if the init parameter exists.
   * <p>
   * You can set the optional tag attribute <b>value</b> to <i>true</i> or
   * <i>false</i>.  The body of the tag is included if existsinitparameter matches
   * the value.
   * <p>
   * JSP Tag Lib Descriptor
   * <p><pre>
   * &lt;name&gt;existsinitparameter&lt;/name&gt;
   * &lt;tagclass&gt;org.apache.taglibs.application.ExistsInitParameterTag&lt;/tagclass&gt;
   * &lt;bodycontent&gt;JSP&lt;/bodycontent&gt;
   * &lt;info&gt;Includes the body of the tag if the init parameter exists.&lt;/info&gt;
   *   &lt;attribute&gt;
   *     &lt;name&gt;name&lt;/name&gt;
   *     &lt;required&gt;true&lt;/required&gt;
   *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
   *   &lt;/attribute&gt;
   *   &lt;attribute&gt;
   *     &lt;name&gt;value&lt;/name&gt;
   *     &lt;required&gt;false&lt;/required&gt;
   *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
   *   &lt;/attribute&gt;
   * </pre>
   *
   * @author Morgan Delagrange
   */
  
  public class ExistsInitParameterTag extends TagSupport
  {
      private String name = null;
      private Boolean value = null;
  
      /**
       * Includes the body of the tag if the init parameter exists.
       *
       * @return SKIP_BODY if existsinitparameter doesn't match value, EVAL_BODY_include if existsinitparameter matches value
       */
      public final int doStartTag() throws JspException
      {
  	boolean result = false;
  	if( pageContext.getServletContext().getInitParameter(name) != null )
  	    result = true;
  
  	if( value == null ) {
  	   if( result )
  		return EVAL_BODY_INCLUDE;
  	   return SKIP_BODY;
  	}
  	if( value.booleanValue() == result )
  	    return EVAL_BODY_INCLUDE;
  	return SKIP_BODY;
      }
  
      /**
       * Set the required tag attribute <b>name</b>. 
       *
       * @param String name of init parameter
       */
      public final void setName(String str)
      {   
  	name = str;
      }
  
      /**
       * Set the optional tag attribute <b>value</b> to true or false. 
       *
       * @param String true or false
       */
      public final void setValue(String str)
      {
  	value = new Boolean(str);
      }
  
  }
  
  
  
  1.1                  jakarta-taglibs/scopes/src/org/apache/taglibs/scopes/InitParametersTag.java
  
  Index: InitParametersTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.taglibs.scopes;
  
  import java.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  
  /**
   * JSP Tag <b>initparameters</b>, used to get init parameters
   * information using the standard JSP 1.2 &lt;jsp:getProperty&gt; tag.
   * <p>
   * The script variable of name <b>id</b> is availble only within the
   * body of the <b>initparameters</b> tag.
   * <p>
   * Loops through all the init parameters in the ServletContext.
   * <p>
   * JSP Tag Lib Descriptor
   * <p><pre>
   * &lt;name&gt;initparameters&lt;/name&gt;
   * &lt;tagclass&gt;org.apache.taglibs.application.InitParametersTag&lt;/tagclass&gt;
   * &lt;teiclass&gt;org.apache.taglibs.application.InitParametersTEI&lt;/teiclass&gt;
   * &lt;bodycontent&gt;JSP&lt;/bodycontent&gt;
   * &lt;info&gt;Loop through all initparameters or get a single initparameter.&lt;/info&gt;
   *   &lt;attribute&gt;
   *     &lt;name&gt;id&lt;/name&gt;
   *     &lt;required&gt;true&lt;/required&gt;
   *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
   *   &lt;/attribute&gt;
   * </pre>
   *
   * @author Morgan Delagrange
   */
  
  public class InitParametersTag extends BodyTagSupport
  {
      private String name = null;
      private ServletContext app = null;
      private Enumeration parameters = null;
      private String paramName = null;
  
      /**
       * Loops through all the init parameters in the current ServletContext.
       *
       * @return SKIP_BODY if no init parameters are found, EVAL_BODY_TAG if an init parameter exists
       */
      public final int doStartTag() throws JspException
      {
  	// Get the ServletContext
  	app = pageContext.getServletContext();
  
  	parameters = app.getInitParameterNames();
  	if( parameters == null || !parameters.hasMoreElements() )
  	    return SKIP_BODY;
  	paramName = (String)parameters.nextElement();
  	if( paramName == null )
  	    return SKIP_BODY;
  
  	pageContext.setAttribute(id,this);
  	return EVAL_BODY_TAG;
      }
  
      /**
       * Method called at end of each initparmaeters tag.
       *
       * @return EVAL_BODY_TAG if there is another init parameter, or SKIP_BODY if there are no more init parameters
       */
      public final int doAfterBody() throws JspException
      {
  	// See if this is the last init parameter
  	if( !parameters.hasMoreElements() )
  	    return SKIP_BODY;
  	// There is another init parameter, so loop again
  	paramName = (String)parameters.nextElement();
  
  	if( paramName == null )
  	    return SKIP_BODY;
  	return EVAL_BODY_TAG;
      }
  
      /**
       * Method called at end of Tag
       * @return EVAL_PAGE
       */
      public final int doEndTag() throws JspException
      {
  	try
  	{
  	    if(bodyContent != null)
  	    bodyContent.writeOut(bodyContent.getEnclosingWriter());
  	} catch(java.io.IOException e)
  	{
  	    throw new JspException("IO Error: " + e.getMessage());
  	}
  	return EVAL_PAGE;
      }
  
      /**
       * Returns the name of the init parameter.
       * <p>
       * &lt;jsp:getProperty name=<i>"id"</i> property="name"/&gt;
       *
       * @return String - init parameter name
       */
      public final String getName()
      {
  	return paramName;
      }
  
      /**
       * Returns the value of the init parameter.
       * <p>
       * &lt;jsp:getProperty name=<i>"id"</i> property="parameter"/&gt;
       *
       * @return String - value of the init parameter
       */
      public final String getParameter()
      {
        String paramValue = app.getInitParameter(paramName);
        if (paramValue == null) {
          return "";
        }
        
        return paramValue;
      }
  
      /**
       * Remove the script variable after attributes tag closed out
       */
      public final void release()
      {
  	if( id != null && id.length() > 0 )
  	    pageContext.removeAttribute(id,PageContext.PAGE_SCOPE);
      }
  }
  
  
  
  1.1                  jakarta-taglibs/scopes/src/org/apache/taglibs/scopes/InitParametersTEI.java
  
  Index: InitParametersTEI.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.taglibs.scopes;
  
  import javax.servlet.jsp.tagext.*;
  
  /**
   * TagExtraInfo for <b>initparameters</b> tag, allows use of standard
   * JSP 1.2 &lt;jsp:getProperty/&gt; with the <b>initparameters</b> tag script
   * variable id.
   *
   * @see InitParametersTag
   *
   * @author Morgan Delagrange
   */
  
  public class InitParametersTEI extends TagExtraInfo
  {
  
      public final VariableInfo[] getVariableInfo(TagData data)
      {
  	return new VariableInfo[]
  	{
  	    new VariableInfo(
  		data.getAttributeString("id"),
  		"org.apache.taglibs.scopes.InitParametersTag",
  		true,
  		VariableInfo.NESTED
  	    ),
  	};
      }
  }
  
  
  
  1.1                  jakarta-taglibs/scopes/src/org/apache/taglibs/scopes/InitParameterTag.java
  
  Index: InitParameterTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.taglibs.scopes;
  
  import java.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  
  /**
   * JSP Tag <b>initparameter</b>, used to output the value for a single
   * init parameter named with <b>name</b>.
   * <p>
   * JSP Tag Lib Descriptor
   * <p><pre>
   * &lt;name&gt;initparameter&lt;/name&gt;
   * &lt;tagclass&gt;org.apache.taglibs.application.InitParameterTag&lt;/tagclass&gt;
   * &lt;bodycontent&gt;empty&lt;/bodycontent&gt;
   * &lt;info&gt;Output the value of a single init parameter.&lt;/info&gt;
   *   &lt;attribute&gt;
   *     &lt;name&gt;name&lt;/name&gt;
   *     &lt;required&gt;true&lt;/required&gt;
   *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
   *   &lt;/attribute&gt;
   * </pre>
   *
   * @author Morgan Delagrange
   */
  
  public class InitParameterTag extends TagSupport
  {
      // Name of init parameter
      private String name = null;
  
      /**
       * Method called at end of Tag to output init parameter value
       *
       * @return EVAL_PAGE
       */
      public final int doEndTag() throws JspException
      {
  	Object value =
  	    pageContext.getServletContext().getInitParameter(name);
  	if( value == null )
  	    value = "";
  
  	try {
  	    pageContext.getOut().write(value.toString());
  	} catch(Exception e) {
  	    throw new JspException("IO Error: " + e.getMessage());
  	}
  
  	return EVAL_PAGE;
      }
  
      /**
       * Set the required tag attribute <b>name</b>. 
       *
       * @param String name of init parameter
       */
      public final void setName(String str)
      {
  	name = str;
      }
  
  }
  
  
  
  1.1                  jakarta-taglibs/scopes/src/org/apache/taglibs/scopes/RemoveAttributeTag.java
  
  Index: RemoveAttributeTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.taglibs.scopes;
  
  import java.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  
  /**
   * JSP Tag <b>removeattribute</b>, used to remove a ServletContext
   * attribute with _name <b>_name</b>.
   * <p>
   * JSP Tag Lib Descriptor
   * <p><pre>
   * &lt;_name&gt;removeattribute&lt;/_name&gt;
   * &lt;tagclass&gt;org.apache.taglibs.application.RemoveAttributeTag&lt;/tagclass&gt;
   * &lt;bodycontent&gt;empty&lt;/bodycontent&gt;
   * &lt;info&gt;Removes an attribute from the ServletContext.&lt;/info&gt;
   *   &lt;attribute&gt;
   *     &lt;_name&gt;_name&lt;/_name&gt;
   *     &lt;required&gt;true&lt;/required&gt;
   *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
   *   &lt;/attribute&gt;
   * </pre>
   *
   * @author Morgan Delagrange
   */
  
  public class RemoveAttributeTag extends BaseScopedTag
  {
      private String _name = null;
  
      /**
       * Removes an attribute from the ServletContext.
       *
       * @return SKIP_BODY
       */
      public final int doStartTag() throws JspException
      {
  	pageContext.removeAttribute(_name,_scope);
  	return SKIP_BODY;
      }
  
      /**
       * Set the required tag attribute <b>_name</b>.
       *
       * @param String _name of application attribute to remove
       */
      public final void setName(String str)
      {   
  	_name = str;
      }
  
  }
  
  
  
  1.1                  jakarta-taglibs/scopes/src/org/apache/taglibs/scopes/SetAttributeTag.java
  
  Index: SetAttributeTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.taglibs.scopes;
  
  import java.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  
  /**
   * JSP Tag <b>setattribute</b>, used to set a ServletContext
   * attribute with _name <b>_name</b> to a String from the body of the tag.
   * <p>
   * JSP Tag Lib Descriptor
   * <p><pre>
   * &lt;_name&gt;setattribute&lt;/_name&gt;
   * &lt;tagclass&gt;org.apache.taglibs.application.SetAttributeTag&lt;/tagclass&gt;
   * &lt;bodycontent&gt;JSP&lt;/bodycontent&gt;
   * &lt;info&gt;Sets an attribute from the ServletContext.&lt;/info&gt;
   *   &lt;attribute&gt;
   *     &lt;_name&gt;_name&lt;/_name&gt;
   *     &lt;required&gt;true&lt;/required&gt;
   *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
   *   &lt;/attribute&gt;
   * </pre>
   *
   * @author Morgan Delagrange
   */
  
  public class SetAttributeTag extends BaseScopedBodyTag
  {
      private String _name = null;
  
      /**
       * Returns EVAL_BODY_TAG so the body of the tag can be evaluated.
       *
       * @return EVAL_BODY_TAG
       */
      public final int doStartTag() throws JspException
      {
  	return EVAL_BODY_TAG;
      }
  
      /**
       * Read the body of the setattribute tag to obtain the attribute value,
       * then set the attribute with <b>_name</b> to that value.
       *
       * @return SKIP_BODY
       */
      public final int doAfterBody() throws JspException
      {
  	// Use the body of the tag as attribute value
  	BodyContent body = getBodyContent();
  	String s = body.getString();
  	// Clear the body since we only used it as input for the attribute
  	// value
  	body.clearBody();
  	// set the attribute
  	pageContext.setAttribute(_name,(Object)s,_scope);
  	return SKIP_BODY;
      }
  
      /**
       * Set the required tag attribute <b>_name</b>.
       *
       * @param String _name of application attribute to set value for
       */
      public final void setName(String str)
      {   
  	_name = str;
      }
  
  }
  
  
  

Mime
View raw message