Skip to content

Commit

Permalink
backported fix for #6263 from 1c05b0b, but no tests
Browse files Browse the repository at this point in the history
Signed-off-by: Greg Wilkins <gregw@webtide.com>
  • Loading branch information
gregw committed Sep 30, 2021
1 parent ebf6d3d commit ec7dc0f
Showing 1 changed file with 11 additions and 4 deletions.
Expand Up @@ -27,6 +27,7 @@
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.jetty.util.URIUtil;

/* ------------------------------------------------------------ */
/** Welcome Filter
Expand All @@ -42,7 +43,8 @@
*
* Requests to "/some/directory" will be redirected to "/some/directory/".
*/
public class WelcomeFilter implements Filter
@Deprecated
public class WelcomeFilter implements Filter
{
private String welcome;

Expand All @@ -59,11 +61,16 @@ public void doFilter(ServletRequest request,
FilterChain chain)
throws IOException, ServletException
{
String path=((HttpServletRequest)request).getServletPath();
if (welcome!=null && path.endsWith("/"))
request.getRequestDispatcher(path+welcome).forward(request,response);
String path = ((HttpServletRequest)request).getServletPath();
if (welcome != null && path.endsWith("/"))
{
String uriInContext = URIUtil.encodePath(URIUtil.addPaths(path, welcome));
request.getRequestDispatcher(uriInContext).forward(request, response);
}
else
{
chain.doFilter(request, response);
}
}

public void destroy() {}
Expand Down

0 comments on commit ec7dc0f

Please sign in to comment.