Bug 66292 - JSP static include broken
Summary: JSP static include broken
Status: RESOLVED DUPLICATE of bug 66277
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 9.0.67
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-02 21:26 UTC by Sander Buskens
Modified: 2022-10-03 08:27 UTC (History)
0 users



Attachments
Webapp with demonstration of static include compile error (1.12 KB, application/zip)
2022-10-02 21:26 UTC, Sander Buskens
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sander Buskens 2022-10-02 21:26:02 UTC
Created attachment 38400 [details]
Webapp with demonstration of static include compile error

Some of our JSP pages with static includes which worked on Tomcat 9.0.65 broke on Tomcat 9.0.67.

The behaviour manifests itself when you static include a JSP page from a subdirectory and then include a JSP from the base directory, like so:

index.jsp contains 2 static includes to:
subdir/subdir_include.jsp <-- this one works
another_include.jsp <-- this one doesn't

Having debugged the code the problem appears to be in the PageController.baseDirStack which looks differently after the subdir/subdir_include.jsp has been processed and the baseDirStack has been popped in PageController.doParse, in 9.0.65 the baseDirStack is defined as a Stack:
    private final Stack<String> baseDirStack = new Stack<>();

and popped near the end of doParse as
        baseDirStack.pop();

In Tomcat 9.0.67 this has now become a:
    private final Queue<String> baseDirStack = new ArrayDeque<>();

and it is popped near the end of doParse as:
        baseDirStack.remove();

On 9.0.67 this returns the wrong baseDir causing the another_include.jsp to not be found.

I have included a test which demonstrates the difference in behaviour of the Stack.pop() and ArrayDeque.remove() and also a simplistic webapp to demonstrate the JSP compilation failure on 9.0.67.

We stumbled on this problem on openjdk 11.0.16.1 but were able to also reproduce it on jdk8.
Comment 1 Mark Thomas 2022-10-03 08:27:41 UTC

*** This bug has been marked as a duplicate of bug 66277 ***