Skip to content

Commit

Permalink
Merge pull request #6943 from eclipse/jetty-9.3.x-6263-welcomefilter
Browse files Browse the repository at this point in the history
backported fix for welcome filter #6263
  • Loading branch information
joakime authored Sep 30, 2021
2 parents ebf6d3d + ec7dc0f commit 1846b28
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
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 1846b28

Please sign in to comment.