<div dir="ltr">Hi,<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jun 6, 2014 at 7:28 PM, Stuart Douglas <span dir="ltr"><<a href="mailto:stuart.w.douglas@gmail.com" target="_blank">stuart.w.douglas@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
"The container may send the request to the welcome resource with a<br>
forward, a redirect, or a container specific mechanism that is<br>
indistinguishable from a direct request."<br>
</blockquote>
<br></div>
It was because of this that I decided to do a full rewrite, which comes under the 'indistinguishable from a direct request' part.</blockquote><div><br></div><div>I can understand that. It's a troublesome section and it makes it very hard to support welcome pages in a universal way (to have an application that directly runs on multiple containers). A forward in the Servlet spec is really a different kind of request with respect to filters etc.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
However, the JavaDoc for HttpServletRequest#<u></u>getRequestURI doesn't seem<br>
to allow this.<br>
</blockquote>
<br></div>
What makes you say that?</blockquote><div><br></div><div>It's more of an interpretation, but the JavaDoc seems to say that it returns the request as it was done by the client. This information is important, since if internal rewrites take place you need this information to render (postback) links that don't expose the name of the rewritten resource. getServletPath() seems to leave a little bit of room to allow it to point to a rewritten resource, as it talks more about the Servlet that is invoked.</div>
<div><br></div><div>But I realize that my interpretation is subjective. </div><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">In general I have been trying to match jboss web's functionality for under specified behaviour such as this.<br>
</blockquote></div>
<br>
If you file a JIRA I will look at changing it in 1.1.<br></blockquote><div><br></div><div>Sure! Thanks in advance.</div><div><br></div><div>Btw, after some fiddling I found that with a handler containing the following code the JBossWeb behavior can be restored:</div>
<div><br></div><div><span style="font-family:arial,sans-serif;font-size:13px">public class RequestURIHandler implements HttpHandler {</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> </span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px"> private HttpHandler next;</span><br style="font-family:arial,sans-serif;font-size:13px"><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> public </span><span style="font-family:arial,sans-serif;font-size:13px">RequestURIHandler</span><span style="font-family:arial,sans-serif;font-size:13px">(</span><span style="font-family:arial,sans-serif;font-size:13px">HttpHandler next) {</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px"> this.next = next;</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> }</span><br style="font-family:arial,sans-serif;font-size:13px">
<br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> @Override</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> public void handleRequest(final HttpServerExchange exchange) throws Exception {</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px"> </span><span style="font-family:arial,sans-serif;font-size:13px"> </span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> String requestURI = exchange.getRequestURI();</span><br style="font-family:arial,sans-serif;font-size:13px">
<br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> next.handleRequest(exchange);</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> </span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px"> exchange.setRequestURI(</span><span style="font-family:arial,sans-serif;font-size:13px">requestURI);</span><br></div><div><span style="font-family:arial,sans-serif;font-size:13px"> }</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px">}</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Which I then register as an initialHandler:</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">public class UndertowHandlerExtension implements ServletExtension {</span><br style="font-family:arial,sans-serif;font-size:13px">
<br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> @Override</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> public void handleDeployment(final DeploymentInfo deploymentInfo, final ServletContext servletContext) {</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px"> deploymentInfo.</span><span style="font-family:arial,sans-serif;font-size:13px">addInitialHandlerChainWrapper(handler -> </span><span style="font-size:13px;font-family:arial,sans-serif">new </span><span style="font-size:13px;font-family:arial,sans-serif">RequestURIHandler</span><span style="font-size:13px;font-family:arial,sans-serif">(</span><span style="font-size:13px;font-family:arial,sans-serif">handler));</span><span style="font-size:13px;font-family:arial,sans-serif"> </span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"> }</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">}</span><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">This seems to work. Is this a correct way?</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Kind regards,</span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Arjan</span></div></div></div></div>