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...@apache.org on 2001/02/12 22:50:03 UTC
cvs commit: jakarta-struts/src/share/org/apache/struts/util ResponseUtils.java
craigmcc 01/02/12 13:50:03
Modified: src/share/org/apache/struts/taglib/logic CompareTagBase.java
ConditionalTagBase.java EqualTag.java
ForwardTag.java GreaterEqualTag.java
GreaterThanTag.java IterateTag.java IterateTei.java
LessEqualTag.java LessThanTag.java
LocalStrings.properties MatchTag.java
NotEqualTag.java NotMatchTag.java
NotPresentTag.java PresentTag.java RedirectTag.java
src/share/org/apache/struts/util ResponseUtils.java
Log:
Clean up source code licenses and refactoring in the struts-logic tag
library.
Revision Changes Path
1.6 +21 -18 jakarta-struts/src/share/org/apache/struts/taglib/logic/CompareTagBase.java
Index: CompareTagBase.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/CompareTagBase.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CompareTagBase.java 2001/01/07 22:39:07 1.5
+++ CompareTagBase.java 2001/02/12 21:49:54 1.6
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/CompareTagBase.java,v 1.5 2001/01/07 22:39:07 craigmcc Exp $
- * $Revision: 1.5 $
- * $Date: 2001/01/07 22:39:07 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/CompareTagBase.java,v 1.6 2001/02/12 21:49:54 craigmcc Exp $
+ * $Revision: 1.6 $
+ * $Date: 2001/02/12 21:49:54 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
* 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
+ * 4. The names "The Jakarta Project", "Struts", 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.
@@ -68,7 +68,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
-import org.apache.struts.action.Action;
+import org.apache.struts.util.MessageResources;
import org.apache.struts.util.PropertyUtils;
import org.apache.struts.util.RequestUtils;
@@ -78,7 +78,7 @@
* define values for desired1 and desired2.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.5 $ $Date: 2001/01/07 22:39:07 $
+ * @version $Revision: 1.6 $ $Date: 2001/02/12 21:49:54 $
*/
public abstract class CompareTagBase extends ConditionalTagBase {
@@ -105,6 +105,14 @@
protected static final int STRING_COMPARE = 2;
+ /**
+ * The message resources for this package.
+ */
+ protected static MessageResources messages =
+ MessageResources.getMessageResources
+ ("org.apache.struts.taglib.logic.LocalStrings");
+
+
// ------------------------------------------------------------ Properties
@@ -211,10 +219,9 @@
Object bean = RequestUtils.lookup(pageContext, name, scope);
if (property != null) {
if (bean == null) {
- JspException e =new JspException
+ JspException e = new JspException
(messages.getMessage("logic.bean", name));
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
+ RequestUtils.saveException(pageContext, e);
throw e;
}
try {
@@ -223,14 +230,12 @@
Throwable t = e.getTargetException();
if (t == null)
t = e;
- pageContext.setAttribute(Action.EXCEPTION_KEY, t,
- PageContext.REQUEST_SCOPE);
+ RequestUtils.saveException(pageContext, t);
throw new JspException
(messages.getMessage("logic.property", name, property,
t.toString()));
} catch (Throwable t) {
- pageContext.setAttribute(Action.EXCEPTION_KEY, t,
- PageContext.REQUEST_SCOPE);
+ RequestUtils.saveException(pageContext, t);
throw new JspException
(messages.getMessage("logic.property", name, property,
t.toString()));
@@ -244,15 +249,13 @@
} else {
JspException e = new JspException
(messages.getMessage("logic.selector"));
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
+ RequestUtils.saveException(pageContext, e);
throw e;
}
if (variable == null) {
JspException e = new JspException
(messages.getMessage("logic.variable", value));
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
+ RequestUtils.saveException(pageContext, e);
throw e;
}
1.5 +7 -7 jakarta-struts/src/share/org/apache/struts/taglib/logic/ConditionalTagBase.java
Index: ConditionalTagBase.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/ConditionalTagBase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ConditionalTagBase.java 2000/12/29 20:36:55 1.4
+++ ConditionalTagBase.java 2001/02/12 21:49:54 1.5
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/ConditionalTagBase.java,v 1.4 2000/12/29 20:36:55 craigmcc Exp $
- * $Revision: 1.4 $
- * $Date: 2000/12/29 20:36:55 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/ConditionalTagBase.java,v 1.5 2001/02/12 21:49:54 craigmcc Exp $
+ * $Revision: 1.5 $
+ * $Date: 2001/02/12 21:49:54 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
* 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
+ * 4. The names "The Jakarta Project", "Struts", 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.
@@ -72,7 +72,7 @@
* Abstract base class for the various conditional evaluation tags.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.4 $ $Date: 2000/12/29 20:36:55 $
+ * @version $Revision: 1.5 $ $Date: 2001/02/12 21:49:54 $
*/
public abstract class ConditionalTagBase extends TagSupport {
@@ -113,7 +113,7 @@
* The message resources for this package.
*/
protected static MessageResources messages =
- MessageResources.getMessageResources
+ MessageResources.getMessageResources
("org.apache.struts.taglib.logic.LocalStrings");
1.3 +6 -6 jakarta-struts/src/share/org/apache/struts/taglib/logic/EqualTag.java
Index: EqualTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/EqualTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EqualTag.java 2000/10/30 06:02:22 1.2
+++ EqualTag.java 2001/02/12 21:49:55 1.3
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/EqualTag.java,v 1.2 2000/10/30 06:02:22 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/10/30 06:02:22 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/EqualTag.java,v 1.3 2001/02/12 21:49:55 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/02/12 21:49:55 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
* 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
+ * 4. The names "The Jakarta Project", "Struts", 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.
@@ -71,7 +71,7 @@
* and value are equal.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/10/30 06:02:22 $
+ * @version $Revision: 1.3 $ $Date: 2001/02/12 21:49:55 $
*/
public class EqualTag extends CompareTagBase {
1.5 +10 -12 jakarta-struts/src/share/org/apache/struts/taglib/logic/ForwardTag.java
Index: ForwardTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/ForwardTag.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ForwardTag.java 2000/10/30 06:02:22 1.4
+++ ForwardTag.java 2001/02/12 21:49:55 1.5
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/ForwardTag.java,v 1.4 2000/10/30 06:02:22 craigmcc Exp $
- * $Revision: 1.4 $
- * $Date: 2000/10/30 06:02:22 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/ForwardTag.java,v 1.5 2001/02/12 21:49:55 craigmcc Exp $
+ * $Revision: 1.5 $
+ * $Date: 2001/02/12 21:49:55 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
* 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
+ * 4. The names "The Jakarta Project", "Struts", 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.
@@ -73,6 +73,7 @@
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionForwards;
import org.apache.struts.util.MessageResources;
+import org.apache.struts.util.RequestUtils;
/**
@@ -80,7 +81,7 @@
* ActionForwards collection associated with our application.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.4 $ $Date: 2000/10/30 06:02:22 $
+ * @version $Revision: 1.5 $ $Date: 2001/02/12 21:49:55 $
*/
public class ForwardTag extends TagSupport {
@@ -145,8 +146,7 @@
if (forward == null) {
JspException e = new JspException
(messages.getMessage("forward.lookup", name));
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
+ RequestUtils.saveException(pageContext, e);
throw e;
}
@@ -158,8 +158,7 @@
try {
response.sendRedirect(response.encodeRedirectURL(path));
} catch (Exception e) {
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
+ RequestUtils.saveException(pageContext, e);
throw new JspException
(messages.getMessage("forward.redirect",
name, e.toString()));
@@ -168,8 +167,7 @@
try {
pageContext.forward(path);
} catch (Exception e) {
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
+ RequestUtils.saveException(pageContext, e);
throw new JspException
(messages.getMessage("forward.forward",
name, e.toString()));
1.3 +6 -6 jakarta-struts/src/share/org/apache/struts/taglib/logic/GreaterEqualTag.java
Index: GreaterEqualTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/GreaterEqualTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- GreaterEqualTag.java 2000/10/30 06:02:22 1.2
+++ GreaterEqualTag.java 2001/02/12 21:49:55 1.3
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/GreaterEqualTag.java,v 1.2 2000/10/30 06:02:22 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/10/30 06:02:22 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/GreaterEqualTag.java,v 1.3 2001/02/12 21:49:55 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/02/12 21:49:55 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
* 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
+ * 4. The names "The Jakarta Project", "Struts", 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.
@@ -71,7 +71,7 @@
* is greater than or equal to the specified value.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/10/30 06:02:22 $
+ * @version $Revision: 1.3 $ $Date: 2001/02/12 21:49:55 $
*/
public class GreaterEqualTag extends CompareTagBase {
1.3 +6 -6 jakarta-struts/src/share/org/apache/struts/taglib/logic/GreaterThanTag.java
Index: GreaterThanTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/GreaterThanTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- GreaterThanTag.java 2000/10/30 06:02:22 1.2
+++ GreaterThanTag.java 2001/02/12 21:49:56 1.3
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/GreaterThanTag.java,v 1.2 2000/10/30 06:02:22 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/10/30 06:02:22 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/GreaterThanTag.java,v 1.3 2001/02/12 21:49:56 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/02/12 21:49:56 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
* 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
+ * 4. The names "The Jakarta Project", "Struts", 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.
@@ -71,7 +71,7 @@
* is greater than the specified value.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/10/30 06:02:22 $
+ * @version $Revision: 1.3 $ $Date: 2001/02/12 21:49:56 $
*/
public class GreaterThanTag extends CompareTagBase {
1.7 +23 -69 jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTag.java
Index: IterateTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTag.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- IterateTag.java 2001/01/16 01:13:50 1.6
+++ IterateTag.java 2001/02/12 21:49:56 1.7
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTag.java,v 1.6 2001/01/16 01:13:50 craigmcc Exp $
- * $Revision: 1.6 $
- * $Date: 2001/01/16 01:13:50 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTag.java,v 1.7 2001/02/12 21:49:56 craigmcc Exp $
+ * $Revision: 1.7 $
+ * $Date: 2001/02/12 21:49:56 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
* 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
+ * 4. The names "The Jakarta Project", "Struts", 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.
@@ -63,19 +63,18 @@
package org.apache.struts.taglib.logic;
-import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
-import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTagSupport;
-import org.apache.struts.action.Action;
import org.apache.struts.util.MessageResources;
import org.apache.struts.util.PropertyUtils;
+import org.apache.struts.util.RequestUtils;
+import org.apache.struts.util.ResponseUtils;
/**
@@ -84,11 +83,9 @@
* can be any of the following: an array of objects, an Iterator,
* a Collection (which includes Lists, Sets and Vectors), or a Map
* (which includes Hashtables) whose elements will be iterated over.
- * <p>
- * <b>NOTE</b> - This tag requires a Java2 (JDK 1.2 or later) platform.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.6 $ $Date: 2001/01/16 01:13:50 $
+ * @version $Revision: 1.7 $ $Date: 2001/02/12 21:49:56 $
*/
public class IterateTag extends BodyTagSupport {
@@ -257,52 +254,18 @@
*/
public int doStartTag() throws JspException {
- // Acquire the collection we are going to iterate over (if necessary)
+ // Acquire the collection we are going to iterate over
Object collection = this.collection;
- if (collection == null) {
- try {
- Object bean = pageContext.findAttribute(name);
- if (bean == null) {
- JspException e = new JspException
- (messages.getMessage("iterate.bean", name));
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
- throw e;
- }
- if (property == null)
- collection = bean;
- else
- collection =
- PropertyUtils.getProperty(bean, property);
- if (collection == null) {
- JspException e = new JspException
- (messages.getMessage("iterate.property",
- name, property));
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
- throw e;
- }
- } catch (IllegalAccessException e) {
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
- throw new JspException
- (messages.getMessage("iterate.access", name, property));
- } 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("iterate.target",
- name, property, t.toString()));
- } catch (NoSuchMethodException e) {
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
- throw new JspException
- (messages.getMessage("iterate.method", name, property));
- }
- }
+ if (collection == null)
+ collection =
+ RequestUtils.lookup(pageContext, name, property, scope);
+ if (collection == null) {
+ JspException e = new JspException
+ (messages.getMessage("iterate.collection"));
+ RequestUtils.saveException(pageContext, e);
+ throw e;
+ }
+
// Construct an iterator for this collection
if (collection.getClass().isArray())
@@ -315,9 +278,8 @@
iterator = ((Map) collection).entrySet().iterator();
else {
JspException e = new JspException
- (messages.getMessage("iterate.iterator", name, property));
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
+ (messages.getMessage("iterate.iterator"));
+ RequestUtils.saveException(pageContext, e);
throw e;
}
@@ -387,16 +349,8 @@
// Render the output from this iteration to the output stream
if (bodyContent != null) {
- try {
- JspWriter out = getPreviousOut();
- out.print(bodyContent.getString());
- bodyContent.clearBody();
- } catch (IOException e) {
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
- throw new JspException
- (messages.getMessage("iterate.io", e.toString()));
- }
+ ResponseUtils.writePrevious(pageContext, bodyContent.getString());
+ bodyContent.clearBody();
}
// Decide whether to iterate or quit
1.4 +6 -6 jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTei.java
Index: IterateTei.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTei.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IterateTei.java 2000/11/28 20:18:46 1.3
+++ IterateTei.java 2001/02/12 21:49:56 1.4
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTei.java,v 1.3 2000/11/28 20:18:46 craigmcc Exp $
- * $Revision: 1.3 $
- * $Date: 2000/11/28 20:18:46 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/IterateTei.java,v 1.4 2001/02/12 21:49:56 craigmcc Exp $
+ * $Revision: 1.4 $
+ * $Date: 2001/02/12 21:49:56 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
* 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
+ * 4. The names "The Jakarta Project", "Struts", 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.
@@ -73,7 +73,7 @@
* tag, identifying the scripting object(s) to be made visible.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.3 $ $Date: 2000/11/28 20:18:46 $
+ * @version $Revision: 1.4 $ $Date: 2001/02/12 21:49:56 $
*/
public class IterateTei extends TagExtraInfo {
1.3 +6 -6 jakarta-struts/src/share/org/apache/struts/taglib/logic/LessEqualTag.java
Index: LessEqualTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/LessEqualTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LessEqualTag.java 2000/10/30 06:02:22 1.2
+++ LessEqualTag.java 2001/02/12 21:49:57 1.3
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/LessEqualTag.java,v 1.2 2000/10/30 06:02:22 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/10/30 06:02:22 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/LessEqualTag.java,v 1.3 2001/02/12 21:49:57 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/02/12 21:49:57 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
* 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
+ * 4. The names "The Jakarta Project", "Struts", 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.
@@ -71,7 +71,7 @@
* is less than or equal to the specified value.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/10/30 06:02:22 $
+ * @version $Revision: 1.3 $ $Date: 2001/02/12 21:49:57 $
*/
public class LessEqualTag extends CompareTagBase {
1.3 +6 -6 jakarta-struts/src/share/org/apache/struts/taglib/logic/LessThanTag.java
Index: LessThanTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/LessThanTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LessThanTag.java 2000/10/30 06:02:22 1.2
+++ LessThanTag.java 2001/02/12 21:49:57 1.3
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/LessThanTag.java,v 1.2 2000/10/30 06:02:22 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/10/30 06:02:22 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/LessThanTag.java,v 1.3 2001/02/12 21:49:57 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/02/12 21:49:57 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
* 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
+ * 4. The names "The Jakarta Project", "Struts", 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.
@@ -71,7 +71,7 @@
* is less than the specified value.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/10/30 06:02:22 $
+ * @version $Revision: 1.3 $ $Date: 2001/02/12 21:49:57 $
*/
public class LessThanTag extends CompareTagBase {
1.4 +6 -10 jakarta-struts/src/share/org/apache/struts/taglib/logic/LocalStrings.properties
Index: LocalStrings.properties
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/LocalStrings.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LocalStrings.properties 2001/02/09 19:33:11 1.3
+++ LocalStrings.properties 2001/02/12 21:49:57 1.4
@@ -1,17 +1,13 @@
forward.forward=Exception forwarding for name {0}: {1}
forward.lookup=Cannot find global ActionForward for name {0}
forward.redirect=Exception redirecting for name {0}: {1}
-iterate.access=Illegal access exception for bean {0} and property {1}
-iterate.bean=No bean found under attribute key {0}
-iterate.io=I/O exception: {0}
-iterate.iterator=Cannot create iterator for bean {0} and property {0}
-iterate.method=No getter method for bean {0} and property {1}
-iterate.property=Null property {1} for bean {0}
-iterate.target=Invocation target exception for bean {0} and property {1}: {2}
+iterate.collection=No collection found
+iterate.iterator=Cannot create iterator for this collection
logic.bean=No bean found under attribute key {0}
-logic.location=Invalid match location {0}
logic.property=Exception accessing property {1} for bean {0}: {2}
logic.selector=No selector attribute (cookie/header/name/parameter) was specified
logic.variable=Cannot compare null variable to value {0}
-redirect.destination=You must specify exactly one of 'forward', 'href', or 'page'
-redirect.redirect=Exception redirecting to {0}: {1}
+redirect.destination=You must specify exactly one of forward, href, or page
+redirect.forward=Missing ActionForward for {0}
+redirect.forwards=Missing ActionForwards collection
+redirect.map=Property {0} of bean {1} is not a Map
1.7 +13 -47 jakarta-struts/src/share/org/apache/struts/taglib/logic/MatchTag.java
Index: MatchTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/MatchTag.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- MatchTag.java 2001/01/07 22:39:07 1.6
+++ MatchTag.java 2001/02/12 21:49:57 1.7
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/MatchTag.java,v 1.6 2001/01/07 22:39:07 craigmcc Exp $
- * $Revision: 1.6 $
- * $Date: 2001/01/07 22:39:07 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/MatchTag.java,v 1.7 2001/02/12 21:49:57 craigmcc Exp $
+ * $Revision: 1.7 $
+ * $Date: 2001/02/12 21:49:57 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
* 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
+ * 4. The names "The Jakarta Project", "Struts", 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.
@@ -63,12 +63,10 @@
package org.apache.struts.taglib.logic;
-import java.lang.reflect.InvocationTargetException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
-import org.apache.struts.action.Action;
import org.apache.struts.util.PropertyUtils;
import org.apache.struts.util.RequestUtils;
@@ -78,7 +76,7 @@
* is a substring of the specified variable.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.6 $ $Date: 2001/01/07 22:39:07 $
+ * @version $Revision: 1.7 $ $Date: 2001/02/12 21:49:57 $
*/
public class MatchTag extends ConditionalTagBase {
@@ -181,53 +179,22 @@
((HttpServletRequest) pageContext.getRequest()).
getHeader(header);
} else if (name != null) {
- Object bean = RequestUtils.lookup(pageContext, name, scope);
- if (bean == null) {
- JspException e = new JspException
- (messages.getMessage("logic.bean", name));
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
- throw e;
- }
- if (property != null) {
- Object propertyValue = null;
- try {
- propertyValue = PropertyUtils.getProperty(bean, property);
- } 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("logic.property", name, property,
- t.toString()));
- } catch (Throwable t) {
- pageContext.setAttribute(Action.EXCEPTION_KEY, t,
- PageContext.REQUEST_SCOPE);
- throw new JspException
- (messages.getMessage("logic.property", name, property,
- t.toString()));
- }
- if (propertyValue != null)
- variable = propertyValue.toString();
- } else {
- variable = bean.toString();
- }
+ Object value =
+ RequestUtils.lookup(pageContext, name, property, scope);
+ if (value != null)
+ variable = value.toString();
} else if (parameter != null) {
variable = pageContext.getRequest().getParameter(parameter);
} else {
JspException e = new JspException
(messages.getMessage("logic.selector"));
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
+ RequestUtils.saveException(pageContext, e);
throw e;
}
if (variable == null) {
JspException e = new JspException
(messages.getMessage("logic.variable", value));
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
+ RequestUtils.saveException(pageContext, e);
throw e;
}
@@ -242,8 +209,7 @@
} else {
JspException e = new JspException
(messages.getMessage("logic.location", location));
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
+ RequestUtils.saveException(pageContext, e);
throw e;
}
1.3 +6 -6 jakarta-struts/src/share/org/apache/struts/taglib/logic/NotEqualTag.java
Index: NotEqualTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/NotEqualTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NotEqualTag.java 2000/10/30 06:02:22 1.2
+++ NotEqualTag.java 2001/02/12 21:49:58 1.3
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/NotEqualTag.java,v 1.2 2000/10/30 06:02:22 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/10/30 06:02:22 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/NotEqualTag.java,v 1.3 2001/02/12 21:49:58 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/02/12 21:49:58 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
* 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
+ * 4. The names "The Jakarta Project", "Struts", 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.
@@ -71,7 +71,7 @@
* and value are not equal.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/10/30 06:02:22 $
+ * @version $Revision: 1.3 $ $Date: 2001/02/12 21:49:58 $
*/
public class NotEqualTag extends CompareTagBase {
1.2 +6 -6 jakarta-struts/src/share/org/apache/struts/taglib/logic/NotMatchTag.java
Index: NotMatchTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/NotMatchTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NotMatchTag.java 2000/09/07 01:35:36 1.1
+++ NotMatchTag.java 2001/02/12 21:49:58 1.2
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/NotMatchTag.java,v 1.1 2000/09/07 01:35:36 craigmcc Exp $
- * $Revision: 1.1 $
- * $Date: 2000/09/07 01:35:36 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/NotMatchTag.java,v 1.2 2001/02/12 21:49:58 craigmcc Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/02/12 21:49:58 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
* 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
+ * 4. The names "The Jakarta Project", "Struts", 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.
@@ -71,7 +71,7 @@
* is not a substring of the specified variable.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.1 $ $Date: 2000/09/07 01:35:36 $
+ * @version $Revision: 1.2 $ $Date: 2001/02/12 21:49:58 $
*/
public class NotMatchTag extends MatchTag {
1.3 +6 -6 jakarta-struts/src/share/org/apache/struts/taglib/logic/NotPresentTag.java
Index: NotPresentTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/NotPresentTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NotPresentTag.java 2000/10/30 06:02:22 1.2
+++ NotPresentTag.java 2001/02/12 21:49:58 1.3
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/NotPresentTag.java,v 1.2 2000/10/30 06:02:22 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/10/30 06:02:22 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/NotPresentTag.java,v 1.3 2001/02/12 21:49:58 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/02/12 21:49:58 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
* 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
+ * 4. The names "The Jakarta Project", "Struts", 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.
@@ -71,7 +71,7 @@
* is not present for this request.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/10/30 06:02:22 $
+ * @version $Revision: 1.3 $ $Date: 2001/02/12 21:49:58 $
*/
public class NotPresentTag extends PresentTag {
1.7 +10 -42 jakarta-struts/src/share/org/apache/struts/taglib/logic/PresentTag.java
Index: PresentTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/PresentTag.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- PresentTag.java 2001/01/07 22:39:07 1.6
+++ PresentTag.java 2001/02/12 21:49:58 1.7
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/PresentTag.java,v 1.6 2001/01/07 22:39:07 craigmcc Exp $
- * $Revision: 1.6 $
- * $Date: 2001/01/07 22:39:07 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/PresentTag.java,v 1.7 2001/02/12 21:49:58 craigmcc Exp $
+ * $Revision: 1.7 $
+ * $Date: 2001/02/12 21:49:58 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
* 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
+ * 4. The names "The Jakarta Project", "Struts", 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.
@@ -63,13 +63,11 @@
package org.apache.struts.taglib.logic;
-import java.lang.reflect.InvocationTargetException;
import java.security.Principal;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
-import org.apache.struts.action.Action;
import org.apache.struts.util.PropertyUtils;
import org.apache.struts.util.RequestUtils;
@@ -79,7 +77,7 @@
* is present for this request.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.6 $ $Date: 2001/01/07 22:39:07 $
+ * @version $Revision: 1.7 $ $Date: 2001/02/12 21:49:58 $
*/
public class PresentTag extends ConditionalTagBase {
@@ -135,38 +133,9 @@
getHeader(header);
present = (value != null);
} else if (name != null) {
- Object bean = RequestUtils.lookup(pageContext, name, scope);
- if (property != null) {
- if (bean == null) {
- JspException e = new JspException
- (messages.getMessage("logic.bean", name));
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
- throw e;
- }
- Object value = null;
- try {
- value = PropertyUtils.getProperty(bean, property);
- } 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("logic.property", name, property,
- t.toString()));
- } catch (Throwable t) {
- pageContext.setAttribute(Action.EXCEPTION_KEY, t,
- PageContext.REQUEST_SCOPE);
- throw new JspException
- (messages.getMessage("logic.property", name, property,
- t.toString()));
- }
- present = (value != null);
- } else {
- present = (bean != null);
- }
+ Object value =
+ RequestUtils.lookup(pageContext, name, property, scope);
+ present = (value != null);
} else if (parameter != null) {
String value =
pageContext.getRequest().getParameter(parameter);
@@ -184,8 +153,7 @@
} else {
JspException e = new JspException
(messages.getMessage("logic.selector"));
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
+ RequestUtils.saveException(pageContext, e);
throw e;
}
1.6 +38 -110 jakarta-struts/src/share/org/apache/struts/taglib/logic/RedirectTag.java
Index: RedirectTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/RedirectTag.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RedirectTag.java 2001/02/09 19:33:11 1.5
+++ RedirectTag.java 2001/02/12 21:49:58 1.6
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/RedirectTag.java,v 1.5 2001/02/09 19:33:11 craigmcc Exp $
- * $Revision: 1.5 $
- * $Date: 2001/02/09 19:33:11 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/RedirectTag.java,v 1.6 2001/02/12 21:49:58 craigmcc Exp $
+ * $Revision: 1.6 $
+ * $Date: 2001/02/12 21:49:58 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
* 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
+ * 4. The names "The Jakarta Project", "Struts", 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.
@@ -64,7 +64,6 @@
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.Map;
@@ -77,17 +76,17 @@
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionForwards;
-import org.apache.struts.util.BeanUtils;
import org.apache.struts.util.MessageResources;
import org.apache.struts.util.PropertyUtils;
import org.apache.struts.util.RequestUtils;
+import org.apache.struts.util.ResponseUtils;
/**
* Generate a URL-encoded redirect to the specified URI.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.5 $ $Date: 2001/02/09 19:33:11 $
+ * @version $Revision: 1.6 $ $Date: 2001/02/12 21:49:58 $
*/
public class RedirectTag extends TagSupport {
@@ -270,12 +269,12 @@
// Perform the redirection
HttpServletResponse response =
(HttpServletResponse) pageContext.getResponse();
- String hyperlink = BeanUtils.filter(hyperlink());
+ String hyperlink = ResponseUtils.filter(hyperlink());
try {
response.sendRedirect(response.encodeRedirectURL(hyperlink));
} catch (IOException e) {
- throw new JspException
- (messages.getMessage("common.io"));
+ RequestUtils.saveException(pageContext, e);
+ throw new JspException(e.getMessage());
}
// Skip the remainder of this apge
@@ -327,8 +326,7 @@
if (n != 1) {
JspException e = new JspException
(messages.getMessage("redirect.destination"));
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
+ RequestUtils.saveException(pageContext, e);
throw e;
}
@@ -345,13 +343,19 @@
ActionForwards forwards = (ActionForwards)
pageContext.getAttribute(Action.FORWARDS_KEY,
PageContext.APPLICATION_SCOPE);
- if (forwards == null)
- throw new JspException
- (messages.getMessage("linkTag.forwards"));
+ if (forwards == null) {
+ JspException e = new JspException
+ (messages.getMessage("redirect.forwards"));
+ RequestUtils.saveException(pageContext, e);
+ throw e;
+ }
ActionForward forward = forwards.findForward(this.forward);
- if (forward == null)
- throw new JspException
- (messages.getMessage("linkTag.forward"));
+ if (forward == null) {
+ JspException e = new JspException
+ (messages.getMessage("redirect.forward", this.forward));
+ RequestUtils.saveException(pageContext, e);
+ throw e;
+ }
HttpServletRequest request =
(HttpServletRequest) pageContext.getRequest();
href = RequestUtils.absoluteURL(request, forward.getPath());
@@ -372,105 +376,29 @@
href += '&';
href += paramId;
href += '=';
- Object bean = RequestUtils.lookup(pageContext,
- paramName, paramScope);
- if (bean != null) {
- if (paramProperty == null)
- href += bean.toString();
- else {
- try {
- Object value =
- PropertyUtils.getProperty(bean, paramProperty);
- if (value != null)
- href += value.toString();
- } catch (IllegalAccessException e) {
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
- throw new JspException
- (messages.getMessage("getter.access",
- paramProperty, paramName));
- } catch (InvocationTargetException e) {
- Throwable t = e.getTargetException();
- pageContext.setAttribute(Action.EXCEPTION_KEY, t,
- PageContext.REQUEST_SCOPE);
- throw new JspException
- (messages.getMessage("getter.result",
- paramProperty, t.toString()));
- } catch (NoSuchMethodException e) {
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
- throw new JspException
- (messages.getMessage("getter.method",
- paramProperty, paramName));
- }
- }
- }
+ Object value =
+ RequestUtils.lookup(pageContext, paramName, paramProperty,
+ paramScope);
+ if (value != null)
+ href += value.toString();
}
// Just return the "href" attribute if there is no bean to look up
- if ((property != null) && (name == null)) {
- JspException e = new JspException
- (messages.getMessage("getter.name"));
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
- throw e;
- }
if (name == null)
return (href);
// Look up the map we will be using
- Object bean = RequestUtils.lookup(pageContext, name, scope);
- if (bean == null) {
- JspException e = new JspException
- (messages.getMessage("getter.bean", name));
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
+ Object value =
+ RequestUtils.lookup(pageContext, name, property, scope);
+ if (value == null)
+ return (href);
+ if (!(value instanceof Map)) {
+ JspException e = new JspException
+ (messages.getMessage("redirect.map", property, name));
+ RequestUtils.saveException(pageContext, e);
throw e;
}
- Map map = null;
- if (property == null) {
- try {
- map = (Map) bean;
- } catch (ClassCastException e) {
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
- throw new JspException
- (messages.getMessage("linkTag.type"));
- }
- } else {
- try {
- map = (Map) PropertyUtils.getProperty(bean, property);
- if (map == null) {
- JspException e = new JspException
- (messages.getMessage("getter.property", property));
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
- throw e;
- }
- } catch (IllegalAccessException e) {
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
- throw new JspException
- (messages.getMessage("getter.access", property, name));
- } catch (InvocationTargetException e) {
- Throwable t = e.getTargetException();
- pageContext.setAttribute(Action.EXCEPTION_KEY, t,
- PageContext.REQUEST_SCOPE);
- throw new JspException
- (messages.getMessage("getter.result",
- property, t.toString()));
- } catch (ClassCastException e) {
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
- throw new JspException
- (messages.getMessage("linkTag.type"));
- } catch (NoSuchMethodException e) {
- pageContext.setAttribute(Action.EXCEPTION_KEY, e,
- PageContext.REQUEST_SCOPE);
- throw new JspException
- (messages.getMessage("getter.method", property, name));
- }
- }
+ Map map = (Map) value;
// Append the required query parameters
StringBuffer sb = new StringBuffer(href);
@@ -478,7 +406,7 @@
Iterator keys = map.keySet().iterator();
while (keys.hasNext()) {
String key = (String) keys.next();
- Object value = map.get(key);
+ value = map.get(key);
if (value == null) {
if (question)
sb.append('&');
1.2 +35 -5 jakarta-struts/src/share/org/apache/struts/util/ResponseUtils.java
Index: ResponseUtils.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/ResponseUtils.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ResponseUtils.java 2001/02/12 00:32:14 1.1
+++ ResponseUtils.java 2001/02/12 21:50:02 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/ResponseUtils.java,v 1.1 2001/02/12 00:32:14 craigmcc Exp $
- * $Revision: 1.1 $
- * $Date: 2001/02/12 00:32:14 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/ResponseUtils.java,v 1.2 2001/02/12 21:50:02 craigmcc Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/02/12 21:50:02 $
*
* ====================================================================
*
@@ -67,6 +67,7 @@
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.tagext.BodyContent;
import org.apache.struts.action.Action;
@@ -75,7 +76,7 @@
* in the Struts controller framework.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.1 $ $Date: 2001/02/12 00:32:14 $
+ * @version $Revision: 1.2 $ $Date: 2001/02/12 21:50:02 $
*/
public class ResponseUtils {
@@ -136,7 +137,10 @@
/**
* Write the specified text as the response to the writer associated with
- * this page.
+ * this page. <strong>WARNING</strong> - If you are writing body content
+ * from the <code>doAfterBody()</code> method of a custom tag class that
+ * implements <code>BodyTag</code>, you should be calling
+ * <code>writePrevious()</code> instead.
*
* @param pageContext The PageContext object for this page
* @param text The text to be written
@@ -147,6 +151,32 @@
throws JspException {
JspWriter writer = pageContext.getOut();
+ try {
+ writer.print(text);
+ } catch (IOException e) {
+ RequestUtils.saveException(pageContext, e);
+ throw new JspException
+ (messages.getMessage("write.io", e.toString()));
+ }
+
+ }
+
+
+ /**
+ * Write the specified text as the response to the writer associated with
+ * the page containing the tag within which we are currently nested.
+ *
+ * @param pageContext The PageContext object for this page
+ * @param text The text to be written
+ *
+ * @exception JspException if an input/output error occurs (already saved)
+ */
+ public static void writePrevious(PageContext pageContext, String text)
+ throws JspException {
+
+ JspWriter writer = pageContext.getOut();
+ while (writer instanceof BodyContent)
+ writer = ((BodyContent) writer).getEnclosingWriter();
try {
writer.print(text);
} catch (IOException e) {