Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backported fix for welcome filter #6263 #6943

Merged
merged 1 commit into from Sep 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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