Hi,

I send patches for bug http://issues.apache.org/bugzilla/show_bug.cgi?id=21408

One patch in RequestProcessor saves errors in sesion in case of redirection.
Patch for TagUtils reads errors from request or reads and removes from session.


--
Radek Wisniewski

Index: RequestProcessor.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-struts/src/share/org/apache/struts/action/RequestProcessor.java,v
retrieving revision 1.32
diff -u -r1.32 RequestProcessor.java
--- RequestProcessor.java       2 Jul 2003 04:06:53 -0000       1.32
+++ RequestProcessor.java       13 Aug 2003 15:23:40 -0000
@@ -409,6 +409,15 @@
         }
         
         if (forward.getRedirect()) {
+            //save errors in session, if any
+            Object errors = request.getAttribute(org.apache.struts.Globals.ERROR_KEY);
+            if(errors != null){
+              //it is not the best place to create session, use "false"
+              HttpSession session = request.getSession(false);
+              if(session != null){
+                session.setAttribute(org.apache.struts.Globals.ERROR_KEY, errors);
+              }
+            }
             // only prepend context path for relative uri
             if (uri.startsWith("/")) {
                 uri = request.getContextPath() + uri;
Index: TagUtils.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-struts/src/share/org/apache/struts/taglib/TagUtils.java,v
retrieving revision 1.22
diff -u -r1.22 TagUtils.java
--- TagUtils.java       2 Aug 2003 22:19:37 -0000       1.22
+++ TagUtils.java       13 Aug 2003 15:23:06 -0000
@@ -636,7 +636,18 @@
 
         ActionErrors errors = new ActionErrors();
 
-        Object value = pageContext.findAttribute(paramName);
+        HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); 
+        Object value = request.getAttribute(paramName);
+        if(value == null){
+          //if it was redirection, errors could be in session
+          HttpSession session = request.getSession(false);
+          if(session != null){
+            value = session.getAttribute(paramName);
+            if(value != null){
+              session.removeAttribute(paramName);
+            }
+          }
+        }
 
         try {
             if (value == null) {

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to