Hal, I just made a commit that fixes the problems you just mentioned, thank you. -----Original Message----- From: Deadman, Hal [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 17, 2001 5:03 PM To: [EMAIL PROTECTED] Subject: RE: cvs commit: jakarta-struts/src/share/org/apache/struts/util R equestUtils.java You are unwrapping the request from the MultipartRequestWrapper object before calling processActionForward() but don't you need to unwrap it before calling processValidate(), processForward(), and processInclude()? All of these may forward the wrapped request object, which won't work. Am I missing something? protected void process(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String contentType = request.getContentType(); String method = request.getMethod(); //if this is a multipart request, wrap the HttpServletRequest object //with a MultipartRequestWrapper to keep the process sub-methods //from failing when checking for certain request parameters //for command tokens and cancel button detection if ((contentType != null) && (contentType.startsWith("multipart/form-data")) && (method.equals("POST"))) { request = new MultipartRequestWrapper(request); } // Identify the path component we will use to select a mapping String path = processPath(request); if (path == null) { if (debug >= 1) log(" No path available for request URI " + request.getRequestURI()); response.sendError(HttpServletResponse.SC_BAD_REQUEST, internal.getMessage("processPath")); return; } if (debug >= 1) log("Processing a " + request.getMethod() + " for " + path); // Automatically select a locale for this user if requested processLocale(request); // Set the content type and no-caching headers if requested processContent(response); processNoCache(response); // General purpose preprocessing hook if (!processPreprocess(request, response)) return; // Look up the corresponding mapping ActionMapping mapping = processMapping(path, request); if (mapping == null) { if (debug >= 1) log(" No mapping available for path " + path); response.sendError(HttpServletResponse.SC_BAD_REQUEST, internal.getMessage("processInvalid", path)); return; } // Process any ActionForm bean related to this request ActionForm formInstance = processActionForm(mapping, request); processPopulate(formInstance, mapping, request); if (!processValidate(mapping, formInstance, request, response)) return; // Execute a forward if specified by this mapping if (!processForward(mapping, request, response)) return; // Execute an include if specified by this mapping if (!processInclude(mapping, request, response)) return; // Acquire the Action instance to process this request Action actionInstance = processActionCreate(mapping, request); if (actionInstance == null) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, internal.getMessage("actionCreate", mapping.getPath())); return; } // Call the Action instance itself ActionForward forward = processActionPerform(actionInstance, mapping, formInstance, request, response); //set the request back to it's normal state if it's currently wrapped, //to avoid ClassCastExceptions from ServletContainers if forwarding if (request instanceof MultipartRequestWrapper) { request = ((MultipartRequestWrapper) request).getRequest(); } // Process the returned ActionForward (if any) processActionForward(forward, mapping, formInstance, request, response); } > -----Original Message----- > From: SCHACHTER,MICHAEL (HP-NewJersey,ex2) [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, May 16, 2001 1:46 PM > To: '[EMAIL PROTECTED]' > Subject: RE: cvs commit: > jakarta-struts/src/share/org/apache/struts/util > R equestUtils.java > > > Hal, > > I'm a little confused, being as I've never seen the components code. > First, > the request is only wrapped for multipart forms. Second, by the time > processForward() is called, it is passed the original request, and not > the > wrapped one. What am I missing? > > -----Original Message----- > From: Deadman, Hal [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, May 15, 2001 5:21 PM > To: [EMAIL PROTECTED] > Cc: 'Cedric Dumoulin' > Subject: RE: cvs commit: > jakarta-struts/src/share/org/apache/struts/util > RequestUtils.java > > > What's the plan regarding forwarding the orignal request > instead of the > wrapped request? Form submissions don't work in the current Struts > build, at > least not on Weblogic 6.0. If ActionServlet is changed to unwrap the > request > before fowarding, Cedric Dumoulin will need to change his Components > code > because he has to copy the processForward() method in his class that > inherits from ActionServlet. But then his components > framework will only > work with the latest struts builds.... > > Error from weblogic when it tries to dispatch to target using wrapped > request: > java.lang.ClassCastException: > org.apache.struts.upload.MultipartRequestWrapper at > weblogic.servlet.internal.RequestDispatcherImpl.forward(Reques > tDispatche > rImp > l.java:112) at > s1.struts.component.ActionComponentServlet.processForward(Acti > onComponen > tSer > vlet.java:198) at > s1.struts.component.ActionComponentServlet.processValidate(Act > ionCompone > ntSe > rvlet.java:158) at > org.apache.struts.action.ActionServlet.process(ActionServlet.j > ava:1553) > at > com.tallan.odtos.web.servlet.AppActionServlet.process > > Hal > > > -----Original Message----- > > From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] > > Sent: Friday, May 11, 2001 7:28 PM > > To: [EMAIL PROTECTED] > > Subject: Re: cvs commit: > > jakarta-struts/src/share/org/apache/struts/util > > RequestUtils.java > > > > > > > > > > On Fri, 11 May 2001, Martin Cooper wrote: > > > > > At 03:44 PM 5/11/01, Craig R. McClanahan wrote: > > > > > > > > > >On 11 May 2001 [EMAIL PROTECTED] wrote: > > > > > > > > > mschachter 01/05/11 15:33:38 > > > > > > > > > > Modified: src/share/org/apache/struts/action Action.java > > > > > ActionServlet.java > > > > > src/share/org/apache/struts/upload > > > > > DiskMultipartRequestHandler.java > > > > > src/share/org/apache/struts/util > > RequestUtils.java > > > > > Added: src/share/org/apache/struts/upload > > > > > MultipartRequestWrapper.java > > > > > Log: > > > > > - Added the MultipartRequestWrapper class, which is > > a class that > > > > implements > > > > > HttpServletRequest and wraps a normal request. > All normal > > > > HttpServletRequest > > > > > methods will be called to the underlying request, > > except for > > > > methods involving > > > > > parameters, which were over-ridden to provide a > > transparent way of > > > > accessing > > > > > multipart elements. The version of the > > HttpServletRequest is > > > > Servlet 2.2, however > > > > > the new methods from Servlet 2.3 are also included > > in this class > > > > with empty > > > > > implementations so that Struts will build against > > the servlet 2.2 > > > > and 2.3 jars > > > > > > > >One thing to remember in 2.2 is that you cannot pass your > > wrapped request > > > >object to a RequestDispatcher.forward() or > > RequestDispatcher.include() > > > >call. In Tomcat 3.x, for example, you'd get a > > ClassCastException error if > > > >you tried to use this in an RD call. > > > > > > You mean if I have an Action that is invoked via POST with > > a file upload, > > > and I try to forward from there using > > mapping.findForward("nextAction"), > > > where the forward has redirect="false, this will fail? This > > would be very > > > bad - in every case where we have a file upload, we > > subsequently forward to > > > another action. > > > > > > > As long as you forward the *original* request object (and not the > > wrapper), you're fine. I'm fighting some security fires on > > Tomcat so I > > haven't had time to look deeply into what Michael is > > changing, but wanted > > to raise the flag in case some assumptions about this were > being made > > incorrectly. > > > > > >Craig > > > > > > -- > > > Martin Cooper > > > > > > > > > > > > > Craig > > > >
RE: cvs commit: jakarta-struts/src/share/org/apache/struts/util R equestUtils.java
SCHACHTER,MICHAEL (HP-NewJersey,ex2) Fri, 18 May 2001 09:57:12 -0700