Skip to content

Commit

Permalink
#2586 JSP as static resource - fix failing Servlet TCK test (#2590)
Browse files Browse the repository at this point in the history
Refactored the welcome files logic
Signed-off-by:Ondrej Mihalyi <[email protected]>
  • Loading branch information
OndroMih authored Jun 11, 2022
1 parent 4ca6dc2 commit 923bf96
Showing 1 changed file with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,35 +230,35 @@ private DefaultServletInvocation getDirectServletInvocationByPath(String servlet
private DefaultServletInvocation getWelcomeFileServletInvocation(String servletPath, String pathInfo) throws IOException {

if (webApplication.getManager().getWelcomeFileManager() != null) {
// Try if we have a welcome file that we can load via the default servlet

for (String welcomeFile : webApplication.getManager().getWelcomeFileManager().getWelcomeFileList()) {
if (!isStaticResource(servletPath, pathInfo + welcomeFile)
|| isJsp(welcomeFile)) {
continue;
}

return getDefaultServletInvocation(servletPath, pathInfo + welcomeFile);
}

// Next try if we have a welcome servlet
for (String welcomeFile : webApplication.getManager().getWelcomeFileManager().getWelcomeFileList()) {
if ( // .jsp files are special in the system, as they are mapped to a servlet, but also
// have to be present at exactly that path as static resource. Additionally we have
// the required index.jsp welcome file, that may not actually be there.
( isJsp(welcomeFile) && !isStaticResource(servletPath, pathInfo + welcomeFile))) {
continue;
DefaultServletInvocation servletInvocation = null;

if (isJsp(welcomeFile)) {
// .jsp files are special in the system, as they are mapped to a servlet, but also
// have to be present at exactly that path as static resource. Additionally we have
// the required index.jsp welcome file, that may not actually be there.
// So, .jsp files are treated as a servlet invocation but only if the static resource exists
if (isStaticResource(servletPath, pathInfo + welcomeFile)) {
servletInvocation = getDirectServletInvocationByPath(servletPath, pathInfo + welcomeFile);
}
} else if (isStaticResource(servletPath, pathInfo + welcomeFile)) {
// If we have a welcome file, we can load it via the default servlet.
return getDefaultServletInvocation(servletPath, pathInfo + welcomeFile);
} else {
// Try if we have a welcome servlet
servletInvocation = getDirectServletInvocationByPath(servletPath, pathInfo + welcomeFile);
}

DefaultServletInvocation servletInvocation = getDirectServletInvocationByPath(servletPath, pathInfo + welcomeFile);
if (servletInvocation != null) {
servletInvocation.setOriginalServletPath(servletPath);
return servletInvocation;
}

return servletInvocation;

}

// No welcome file or servlet
// No static file, JSP or servlet
}

return null;
Expand Down

0 comments on commit 923bf96

Please sign in to comment.