Martin,
I looked into this a little deeper and I'm slightly baffled by something.
javax.servlet.RequestDispatcher.forward(request,response);
This method pretty much manages the forwarding of requests, and is what is used by the Servlet API and the JSP API's when doing forwarding. If I understand correctly, its behavior is such that when it is gotten from the servlet context using
context.getRequestDispatcher(uri);
if the uri has request parameters, then the Dispatcher manages to overload the request parameters with those encoded in the uri.
So I go to the Stuts code that facilitates forwarding
RequestProcessor.doForward(...)
and I find that it is (of course) using this facility properly
protected void doForward(
String uri,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Unwrap the multipart request, if there is one.
if (request instanceof MultipartRequestWrapper) {
request = ((MultipartRequestWrapper) request).getRequest();
}
RequestDispatcher rd = getServletContext().getRequestDispatcher(uri);
if (rd == null) {
response.sendError(
HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
getInternal().getMessage("requestDispatcher", uri));
return;
}
rd.forward(request, response);
}
So this makes me suspect that Struts is actually unneccessarily encoding the request parameters onto the "uri" (plusthe ones I add) prior to making this call to doForward, but I havn't yet gotten this deep.
Does this make sense? This is why I believe the parameters would be duplicated in my code when I add them by appending them to the uri.
-Mark
Mark R. Diggory wrote:
Martin Cooper wrote:
On Thu, 17 Jun 2004, Mark R. Diggory wrote:
I just finally joined the dev list
Welcome!
, so pardon if this might be an old subject but...
It's been discussed a few times.
I came up with a simple Extension to ActionForward to manage the addition of parameters in the forwards request and posted it on the wiki. I have a version with even more functionality which allows the replacing and removal of parameters and specific values of a parameter. Is this something the project would have an interest in?
What is the purpose of the constructor which takes a request? Given that any request parameters will still exist as parameters if the request is forwarded, I would expect the original parameters to be duplicated if this constructor is used and the request is forwarded. No?
Wow, I tested it, and your right. This will only work for a redirect, otherwise it duplicates the parameters (logical, and an oversight on my part).
I think the answer to what the behavior should be in this case, and in the case of the feature request in bug tracking can be seen in the basic behavior of the jsp taglibrary:
-- Martin Cooper
In the following case, the forward supplies only the "test2" parameter. Whereas:
<jsp:forward page="Test2.jsp"> <jsp:param name="test2" value="test2"/> </jsp:forward>
This forward supplies the parameters that were in the original request. <jsp:forward page="Test2.jsp"/>
So this sort of thing has been considered before, prior to Struts... Its Apache code, or its probibly accessable in the JSP spec if it is not?
-Mark
------------------------------------------------------------------------
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]