-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Issue with Configuring Specific Static Resources in the same base directory ee10 jetty 12.0.10 #11880
Comments
Can you show examples of resource requests that fail? |
The issue only serving the /index.html |
Call I say this, because you are not checking that the line What is |
You are using Windows (and important thing to note when working with File System issues on Java). Can you access some of the static resources? or none of them? Is the path |
I can access to all the static resources except index.html. For example, I can access to static resources that end with .js. However, I can't access the static resource index.html. Here is my configuration:
|
Can you please copy/paste? |
You only need 1 If you want welcome file behavior, use one of the |
If I want to specify a configuration for the static resource index.html, for example, or for other resources ending with .js, because not all of them have the same InitParameter? ServletHolder holderAlt = new ServletHolder("static", DefaultServlet.class);
holderAlt.setInitParameter("dirAllowed", "false");
holderAlt.setInitParameter("cacheControl", "no-store");
context.addServlet(holderAlt, "/index.html");
ServletHolder holderDef = new ServletHolder("default", DefaultServlet.class);
holderDef.setInitParameter("dirAllowed", "true");
context.addServlet(holderDef, "/"); For the static resource index.html, we have set |
|
so I cannot assign special configurations for non-default DefaultServlets? |
You can, but there are restrictions.
|
Thanks for this information. so If I need to configure the static resource index.html, I must place this file in a different base resource and then add the baseResource parameter to the ServletHolder |
The static resource Why do you need an entirely separate DefaultServlet for a precise / absolute-path url-pattern? |
I see a serious regression with the DefaultServlet in EE10 compared to EE9. |
Why do you need that? If it's just for Cache-Control, then you are doing this entirely in the wrong place, as Cache-Control is applied to all resources in the entire Base Resource, not specific entries based on the DefaultServlet. (the Cache-Control init-param in DefaultServlet just configures the low level ResourceService which handles serving content from the Base Resource) The whole point of serving static files from DefaultServlet is to serve them from a Base Resource. Take this for example...
That request will result in a lookup against the Base Resource + (Path-In-Context). If you have an absolute-path url-pattern of say Then with all of this you are still not handling welcome file logic at all with your Cache-Control. If you have specific Cache-Control behavior, that's not handled via DefaultServlet configuration, but rather by paying attention to the Response Content-Type and from where that response was generated (eg: the request path, but don't forget about welcome-files logic!). This is typically done via custom Servlet filters setup against specific paths. |
@Emilyserap see my comment over on this other issue here: #11884 (comment). It's not a regression, |
Thanks for the explanation. Otherwise, when will the ResourceServlet be ready? |
@Emilyserap #11933 has been merged into jetty-12.0.x, so should be part of this month's 12.0.12 release. |
Jetty version(s)
12.0.10
Jetty Environment
ee10
Java version/vendor
17
Description
I am encountering an issue while configuring specific static resources in the same base directory. When I try to access these resources, I receive a HTTP ERROR 404 Not Found
The text was updated successfully, but these errors were encountered: