You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@locus.apache.org on 2000/10/13 01:17:18 UTC

cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/bean DefineTag.java IncludeTag.java ResourceTag.java WriteTag.java

craigmcc    00/10/12 16:17:18

  Modified:    src/share/org/apache/struts/taglib/bean DefineTag.java
                        IncludeTag.java ResourceTag.java WriteTag.java
  Log:
  Store the exception we are about to throw as a request attribute.
  
  Revision  Changes    Path
  1.3       +15 -4     jakarta-struts/src/share/org/apache/struts/taglib/bean/DefineTag.java
  
  Index: DefineTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/DefineTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefineTag.java	2000/08/31 00:11:15	1.2
  +++ DefineTag.java	2000/10/12 23:17:15	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/DefineTag.java,v 1.2 2000/08/31 00:11:15 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/08/31 00:11:15 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/DefineTag.java,v 1.3 2000/10/12 23:17:15 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/10/12 23:17:15 $
    *
    * ====================================================================
    *
  @@ -68,6 +68,7 @@
   import javax.servlet.jsp.JspException;
   import javax.servlet.jsp.PageContext;
   import javax.servlet.jsp.tagext.TagSupport;
  +import org.apache.struts.action.Action;
   import org.apache.struts.util.BeanUtils;
   import org.apache.struts.util.MessageResources;
   import org.apache.struts.util.PropertyUtils;
  @@ -78,7 +79,7 @@
    * bean property.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/08/31 00:11:15 $
  + * @version $Revision: 1.3 $ $Date: 2000/10/12 23:17:15 $
    */
   
   public final class DefineTag extends TagSupport {
  @@ -194,17 +195,27 @@
                   value = PropertyUtils.getProperty(bean, property);
   
           } catch (IllegalAccessException e) {
  +            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
  +                                     PageContext.REQUEST_SCOPE);
               throw new JspException
                   (messages.getMessage("getter.access", property, name));
   	} catch (IllegalArgumentException e) {
  +            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
  +                                     PageContext.REQUEST_SCOPE);
   	    throw new JspException
   	      (messages.getMessage("getter.scope", scope));
           } catch (InvocationTargetException e) {
               Throwable t = e.getTargetException();
  +            if (t == null)
  +                t = e;
  +            pageContext.setAttribute(Action.EXCEPTION_KEY, t,
  +                                     PageContext.REQUEST_SCOPE);
               throw new JspException
                   (messages.getMessage("getter.invocation",
                                        property, name, t.toString()));
           } catch (NoSuchMethodException e) {
  +            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
  +                                     PageContext.REQUEST_SCOPE);
               throw new JspException
                   (messages.getMessage("getter.method", property, name));
           }
  
  
  
  1.3       +7 -2      jakarta-struts/src/share/org/apache/struts/taglib/bean/IncludeTag.java
  
  Index: IncludeTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/IncludeTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IncludeTag.java	2000/09/05 01:52:34	1.2
  +++ IncludeTag.java	2000/10/12 23:17:16	1.3
  @@ -1,5 +1,5 @@
   /*
  - * $Id: IncludeTag.java,v 1.2 2000/09/05 01:52:34 craigmcc Exp $
  + * $Id: IncludeTag.java,v 1.3 2000/10/12 23:17:16 craigmcc Exp $
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -69,6 +69,7 @@
   import javax.servlet.jsp.JspException;
   import javax.servlet.jsp.PageContext;
   import javax.servlet.jsp.tagext.TagSupport;
  +import org.apache.struts.action.Action;
   import org.apache.struts.util.MessageResources;
   
   
  @@ -80,7 +81,7 @@
    * wrapped response passed to RequestDispatcher.include().
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/09/05 01:52:34 $
  + * @version $Revision: 1.3 $ $Date: 2000/10/12 23:17:16 $
    */
   
   public class IncludeTag extends TagSupport {
  @@ -171,6 +172,8 @@
   	    conn.setDoOutput(false);
   	    conn.connect();
   	} catch (Exception e) {
  +            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
  +                                     PageContext.REQUEST_SCOPE);
   	    throw new JspException
                   (messages.getMessage("include.open", name, e.toString()));
   	}
  @@ -191,6 +194,8 @@
   	    }
               in.close();
   	} catch (Exception e) {
  +            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
  +                                     PageContext.REQUEST_SCOPE);
               throw new JspException
                   (messages.getMessage("include.read", name, e.toString()));
   	}
  
  
  
  1.3       +7 -4      jakarta-struts/src/share/org/apache/struts/taglib/bean/ResourceTag.java
  
  Index: ResourceTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/ResourceTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ResourceTag.java	2000/09/05 01:52:34	1.2
  +++ ResourceTag.java	2000/10/12 23:17:16	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/ResourceTag.java,v 1.2 2000/09/05 01:52:34 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/09/05 01:52:34 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/ResourceTag.java,v 1.3 2000/10/12 23:17:16 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/10/12 23:17:16 $
    *
    * ====================================================================
    *
  @@ -70,6 +70,7 @@
   import javax.servlet.jsp.JspException;
   import javax.servlet.jsp.PageContext;
   import javax.servlet.jsp.tagext.TagSupport;
  +import org.apache.struts.action.Action;
   import org.apache.struts.util.MessageResources;
   import org.apache.struts.util.PropertyUtils;
   
  @@ -80,7 +81,7 @@
    * web application resource.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/09/05 01:52:34 $
  + * @version $Revision: 1.3 $ $Date: 2000/10/12 23:17:16 $
    */
   
   public final class ResourceTag extends TagSupport {
  @@ -185,6 +186,8 @@
   	    reader.close();
   	    pageContext.setAttribute(id, sb.toString());
   	} catch (IOException e) {
  +            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
  +                                     PageContext.REQUEST_SCOPE);
   	    throw new JspException
   	      (messages.getMessage("getter.resource", name));
   	}
  
  
  
  1.3       +19 -4     jakarta-struts/src/share/org/apache/struts/taglib/bean/WriteTag.java
  
  Index: WriteTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/WriteTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WriteTag.java	2000/09/05 21:25:45	1.2
  +++ WriteTag.java	2000/10/12 23:17:16	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/WriteTag.java,v 1.2 2000/09/05 21:25:45 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/09/05 21:25:45 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/WriteTag.java,v 1.3 2000/10/12 23:17:16 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/10/12 23:17:16 $
    *
    * ====================================================================
    * 
  @@ -69,6 +69,7 @@
   import javax.servlet.jsp.JspWriter;
   import javax.servlet.jsp.PageContext;
   import javax.servlet.jsp.tagext.TagSupport;
  +import org.apache.struts.action.Action;
   import org.apache.struts.util.BeanUtils;
   import org.apache.struts.util.MessageResources;
   import org.apache.struts.util.PropertyUtils;
  @@ -80,7 +81,7 @@
    * output stream, optionally filtering characters that are sensitive in HTML.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/09/05 21:25:45 $
  + * @version $Revision: 1.3 $ $Date: 2000/10/12 23:17:16 $
    */
   
   public final class WriteTag extends TagSupport {
  @@ -174,6 +175,8 @@
               try {
                   bean = BeanUtils.lookup(pageContext, name, scope);
               } catch (IllegalArgumentException e) {
  +                pageContext.setAttribute(Action.EXCEPTION_KEY, e,
  +                                         PageContext.REQUEST_SCOPE);
                   throw new JspException
                       (messages.getMessage("getter.scope", scope));
               }
  @@ -196,17 +199,27 @@
   	        value = value.toString();
   
           } catch (IllegalAccessException e) {
  +            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
  +                                     PageContext.REQUEST_SCOPE);
               throw new JspException
                   (messages.getMessage("getter.access", property, name));
   	} catch (IllegalArgumentException e) {
  +            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
  +                                     PageContext.REQUEST_SCOPE);
   	    throw new JspException
   	      (messages.getMessage("getter.argument", e.toString()));
           } catch (InvocationTargetException e) {
               Throwable t = e.getTargetException();
  +            if (t == null)
  +                t = e;
  +            pageContext.setAttribute(Action.EXCEPTION_KEY, t,
  +                                     PageContext.REQUEST_SCOPE);
               throw new JspException
                   (messages.getMessage("getter.invocation",
                                        property, name, t.toString()));
           } catch (NoSuchMethodException e) {
  +            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
  +                                     PageContext.REQUEST_SCOPE);
               throw new JspException
                   (messages.getMessage("getter.method", property, name));
           }
  @@ -220,6 +233,8 @@
   	    else
   	        writer.print((String) value);
   	} catch (IOException e) {
  +            pageContext.setAttribute(Action.EXCEPTION_KEY, e,
  +                                     PageContext.REQUEST_SCOPE);
   	    throw new JspException
   		(messages.getMessage("getter.io", e.toString()));
   	}