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

Ensure jetty api servlets/filters take precedence over webdefault.xml declarations. #10661

Closed
janbartel opened this issue Oct 4, 2023 · 1 comment · Fixed by #10668
Closed
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@janbartel
Copy link
Contributor

Jetty version(s)
12.0.x

Jetty Environment
ee8, ee9, ee10

During the investigations for #10652 it was discovered that a DefaultServlet and JettyJspServlet - defined and mapped to / and *.jsp respectively via the jetty api - lead to duplicate mappings when combined with the declarations in webdefault.xml.

For example, given the jetty code:

WebAppContext webapp = new WebAppContext();
webapp.getServletHandler().addServletWithMapping(DefaultServlet.class.getName(), "/");
webapp.getServletHandler().addServletWithMapping(MySpecialJspServlet.class.getName(), "*.jsp");

and the contents of webdefault.xml being:

  <servlet>
    <servlet-name>default</servlet-name>
    <servlet-class>org.eclipse.jetty.ee10.servlet.DefaultServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>

  <servlet id="jsp">
    <servlet-name>jsp</servlet-name>
    <servlet-class>org.eclipse.jetty.ee10.jsp.JettyJspServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>*.jsp</url-pattern>
    <url-pattern>*.jspf</url-pattern>
    <url-pattern>*.jspx</url-pattern>
    <url-pattern>*.xsp</url-pattern>
    <url-pattern>*.JSP</url-pattern>
    <url-pattern>*.JSPF</url-pattern>
    <url-pattern>*.JSPX</url-pattern>
    <url-pattern>*.XSP</url-pattern>
  </servlet-mapping>

the result is 2 different DefaultServlet instances both mapped to / and 2 different jsp servlets, both mapped to *.jsp:

|     |  |  |  +> servlets oeje10s.ServletHandler@55ab5a0b{STARTED} size=4
|     |  |  |  |  +> org.eclipse.jetty.ee10.servlet.DefaultServlet-ad72ea0==org.eclipse.jetty.ee10.servlet.DefaultServlet@252bd084
|     |  |  |  |  +> MySpecialJspServlet-26dae73f==MySpecialJspServlet@5e45d115
|     |  |  |  |  +> default==org.eclipse.jetty.ee10.servlet.DefaultServlet@5c13d641
|     |  |  |  |  +> jsp==org.eclipse.jetty.ee10.jsp.JettyJspServlet@19c47
|     |  |  |  +> servletMappings oeje10s.ServletHandler@55ab5a0b{STARTED} size=4
|     |  |  |  |  +> [/]=>org.eclipse.jetty.ee10.servlet.DefaultServlet-ad72ea0
|     |  |  |  |  +> [*.jsp]=>MySpecialJspServlet-26dae73f
|     |  |  |  |  +> [/]=>default
|     |  |  |  |  +> [*.jsp, *.jspf, *.jspx, *.xsp, *.JSP, *.JSPF, *.JSPX, *.XSP]=>jsp
@janbartel janbartel added the Bug For general bugs on Jetty side label Oct 4, 2023
@janbartel janbartel self-assigned this Oct 4, 2023
@gregw gregw moved this to 🏗 In progress in Jetty 12.0.3 Oct 11, 2023
@joakime joakime moved this to 👀 In review in Jetty 12.0.3 - FROZEN Oct 12, 2023
@joakime joakime moved this from 👀 In review to 🏗 In progress in Jetty 12.0.3 - FROZEN Oct 12, 2023
janbartel added a commit that referenced this issue Oct 19, 2023
…ebdefault (#10668)

* Issue #10661 Allow jetty api to override servlets and mappings from webdefault

---------

Co-authored-by: Greg Wilkins <gregw@webtide.com>
@janbartel
Copy link
Contributor Author

Fixed via #10668

@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Jetty 12.0.3 - FROZEN Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
No open projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

1 participant