jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sh...@apache.org
Subject cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/core RedirectTag.java
Date Sat, 09 Mar 2002 00:17:14 GMT
shawn       02/03/08 16:17:14

  Added:       standard/src/org/apache/taglibs/standard/tag/common/core
                        RedirectSupport.java
               standard/src/org/apache/taglibs/standard/tag/el/core
                        RedirectTag.java
               standard/src/org/apache/taglibs/standard/tag/rt/core
                        RedirectTag.java
  Log:
  Darn stragglers...
  
  Revision  Changes    Path
  1.1                  jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/core/RedirectSupport.java
  
  Index: RedirectSupport.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.standard.tag.common.core;
  
  import java.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  import java.net.URLEncoder;
  import org.apache.taglibs.standard.resources.Resources;
  
  /**
   * <p>Support for tag handlers for &lt;redirect&gt;, JSTL 1.0's tag
   * for redirecting to a new URL (with optional query parameters).</p>
   *
   * @author Shawn Bayern
   */
  
  public abstract class RedirectSupport extends BodyTagSupport
      implements ParamParent {
  
      //*********************************************************************
      // Protected state
  
      protected String url;                        // 'url' attribute
  
      //*********************************************************************
      // Private state
  
      private String var;                          // 'var' attribute
      private int scope;				 // processed 'scope' attr
      private ParamSupport.ParamManager params;	 // added parameters
  
      //*********************************************************************
      // Constructor and initialization
  
      public RedirectSupport() {
  	super();
  	init();
      }
  
      private void init() {
  	url = var = null;
  	params = null;
  	scope = PageContext.PAGE_SCOPE;
      }
  
  
     //*********************************************************************
      // Tag attributes known at translation time
  
      public void setVar(String var) {
          this.var = var;
      }
  
      public void setScope(String scope) {
  	this.scope = Util.getScope(scope);
      }
  
  
      //*********************************************************************
      // Collaboration with subtags
  
      // inherit Javadoc
      public void addParameter(String name, String value) {
  	params.addParameter(name, value);
      }
  
  
      //*********************************************************************
      // Tag logic
  
      // resets any parameters that might be sent
      public int doStartTag() throws JspException {
  	params = new ParamSupport.ParamManager();
  	return EVAL_BODY_BUFFERED;
      }
  
  
      // gets the right value, encodes it, and prints or stores it
      public int doEndTag() throws JspException {
  	String result;				// the eventual result
  
  	// add (already encoded) parameters
  	result = params.aggregateParams(url);
  
          // if the URL is relative, rewrite it with 'redirect' encoding rules
          HttpServletResponse response =
              ((HttpServletResponse) pageContext.getResponse());
          if (!ImportSupport.isAbsoluteUrl(result))
              result = response.encodeRedirectURL(result);
  
  	// redirect!
  	try {
  	    response.sendRedirect(result);
  	} catch (java.io.IOException ex) {
  	    throw new JspTagException(ex.toString());
  	}
  
  	return SKIP_PAGE;
      }
  
      // Releases any resources we may have (or inherit)
      public void release() {
  	init();
      }
  }
  
  
  
  1.1                  jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/core/RedirectTag.java
  
  Index: RedirectTag.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.standard.tag.el.core;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  import org.apache.taglibs.standard.tag.common.core.*;
  
  /**
   * <p>A handler for &lt;redirect&gt;, which redirects the browser to a
   * new URL.
   *
   * @author Shawn Bayern
   */
  
  public class RedirectTag extends RedirectSupport {
  
      //*********************************************************************
      // 'Private' state (implementation details)
  
      private String url_;			// stores EL-based property
  
  
      //*********************************************************************
      // Constructor
  
      /**
       * Constructs a new URLEncodeTag.  As with TagSupport, subclasses
       * should not provide other constructors and are expected to call
       * the superclass constructor
       */
      public RedirectTag() {
          super();
          init();
      }
  
  
      //*********************************************************************
      // Tag logic
  
      // evaluates expression and chains to parent
      public int doStartTag() throws JspException {
  
          // evaluate any expressions we were passed, once per invocation
          evaluateExpressions();
  
  	// chain to the parent implementation
  	return super.doStartTag();
      }
  
  
      // Releases any resources we may have (or inherit)
      public void release() {
          super.release();
          init();
      }
  
  
      //*********************************************************************
      // Accessor methods
  
      public void setUrl(String url_) {
          this.url_ = url_;
      }
  
      //*********************************************************************
      // Private (utility) methods
  
      // (re)initializes state (during release() or construction)
      private void init() {
          // null implies "no expression"
  	url_ = null;
      }
  
      /* Evaluates expressions as necessary */
      private void evaluateExpressions() throws JspException {
          /* 
           * Note: we don't check for type mismatches here; we assume
           * the expression evaluator will return the expected type
           * (by virtue of knowledge we give it about what that type is).
           * A ClassCastException here is truly unexpected, so we let it
           * propagate up.
           */
  
  	url = (String) ExpressionUtil.evalNotNull(
  	    "import", "url", url_, String.class, this, pageContext);
      }
  }
  
  
  
  1.1                  jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/core/RedirectTag.java
  
  Index: RedirectTag.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.standard.tag.rt.core;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  import org.apache.taglibs.standard.tag.common.core.*;
  
  /**
   * <p>A handler for &lt;redirect&gt; that supports rtexprvalue-based
   * attributes.</p>
   *
   * @author Shawn Bayern
   */
  
  public class RedirectTag extends RedirectSupport {
  
      //*********************************************************************
      // Accessor methods
  
      // for tag attribute
      public void setUrl(String url) throws JspTagException {
          this.url = url;
      }
  
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>


Mime
View raw message