RE: cvs commit: jakarta-struts/src/share/org/apache/struts/util R equestUtils.java

2001-05-18 Thread SCHACHTER,MICHAEL (HP-NewJersey,ex2)

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 req

RE: cvs commit: jakarta-struts/src/share/org/apache/struts/util R equestUtils.java

2001-05-17 Thread Deadman, Hal

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/s