The result is that nothing appears to be found in the context. Neither values that were set from a previous template with #set($title = "foo") nor values that exist in the request attribute collection are found. The output just has the literals $title and $wrapped in it.
According to my debugging code, I *am* successfully obtaining the same ChainedContext from the request collection. It just doesn't seem to contain any of the stuff I expect it to. What I'm doing is executing the first velocity template with RequestDispatcher.include() to the VelocityViewServlet (using a HttpServletResponseWrapper that simply buffers the output), then executing the second velocity template using RequestDispatcher.forward(). The buffered output of the first template is stored in the request attribute collection as a String with the key "wrapped". This is all within the same http request. So this *should* work? Thanks, Jeff Schnitzer [EMAIL PROTECTED] > -----Original Message----- > From: Gabriel Sidler [mailto:[EMAIL PROTECTED]] > Sent: Thursday, March 07, 2002 7:31 AM > To: Velocity Developers List > Cc: Jeff Schnitzer > Subject: Re: [viewservlet] oddities with the ChainedContext > > Jeff Schnitzer wrote: > > > > I'm trying to patch the VelocityViewServlet so that the same context is > > used for multiple includes/forwards during a single request. However, I > > seem to be hwarted by some unknown and malevolent force :-) > > > > My first thought is to simply save the ChainedContext in the request > > attributes and extract for subsequent requests in > > VelocityViewServlet.createContext(), like this: > > > > ChainedContext ctx; > > > > if (persistentContextKey == null) > > { > > ctx = new ChainedContext( null, request, response, > > getServletContext() ); > > } > > else > > { > > ctx = (ChainedContext)request.getAttribute( > > persistentContextKey ); > > > > if (ctx == null) > > { > > ctx = new ChainedContext( null, request, > > response, getServletContext() ); > > request.setAttribute( persistentContextKey, ctx > > ); > > } > > } > > > > Jeff, > what you do looks perfectly ok to me. > > > However, this doesn't work, for reasons which apparently require more > > understanding of Velocity architecture than I possess. > > How does it not work? > > > I can understand > > some undesirable behavior here because the request and response objects > > might have been substituted at the second invocation, but in my example > > that isn't the case. And without any way of extracting the Map out of > > the context, there doesn't seem to be much I can do about it. > > Which Map, which context? Are you saying you can't find the Velocity > context anymore that you stuck into the request attributes? Is is really > the same request? > > > > > Can anyone shed any light on the problem? > > How do you pass control between servlets? > > > Gabe > > > > -- > Gabriel Sidler > Software Engineer, Eivycom GmbH, Zurich, Switzerland -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
