On 1/21/06, Richard Wallace <[EMAIL PROTECTED]> wrote: > > Hello again, > > I'm running into a problem getting my /index.jsp to forward to a Clay > HTML page. The index.jsp page just contains the following: > > <jsp:forward page="default.html"/> > > > When I try to hit it with the URL > http://localhost:8080/shale-clay-example/ I get a 404 saying that > default.jsp cannot be found. If I goto > http://localhost:8080/shale-clay-example/default.html it works just fine. > > Can I not forward to the default page like this? I also tried setting > default.html as the welcome-file in the web.xml, but that didn't work (I > didn't really expect it to). Any idea what the problem is?
What container are you running on? In particular, is it based on Servlet 2.3 or 2.4? The reason this is important is that a RequestDispatcher.forward() (which is what a <jsp:forward> does under the covers) does *not* necessarily go through the entire lifecycle that an HTTP request to the forwarded-to URL would go to. In the particular case here, it's important that a request for a Clay-served view has to go through the Shale filter to do the approprate processing. This is impossible in a Servlet 2.3 environment, because filters are defined to *only* be applied on the original request, not on forwards. In a Servlet 2.4 environment (such as Tomcat 5.x), this remains the default ... but you can ask for filters to be applied by modifying your filter mapping declaration: <filter-mapping> <filter-name>shale</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping> This changes the default behavior (which only applies filters to requests) to apply the Shale filter to both requests and forwards. This *should* address the use case you are describing. Thanks, > Rich Craig