Class StaticFilesServlet
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.apache.juneau.rest.server.servlet.RestServlet
org.apache.juneau.rest.server.staticfile.StaticFilesServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
Standalone servlet companion of the
StaticFilesMixin mixin.
Mounts as a sibling top-level servlet at /static/* and serves static files by
delegating to the flavor-neutral StaticFiles worker bean resolved from the request context
(RestContext.getStaticFiles()) — the same worker the mixin
and child flavors use, so the forms cannot drift.
Whereas the StaticFilesMixin mixin pins its op at /static/* for composition
into a host at /, this companion declares the mount at the class level
(@Rest(paths="/static/*")) and pins the ops at /* — eliminating
the path-doubling that a mixin-shaped op would produce when the servlet itself is mounted at
/static/*.
Microservice registration:
See Also:
- Since:
- 10.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.juneau.rest.server.servlet.RestServlet
RestServlet.Builder<R extends RestServlet,SELF extends RestServlet.Builder<R, SELF>>, RestServlet.DefaultBuilder<R extends RestServlet> -
Field Summary
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetStaticFile(RestRequest req, String path, Locale locale) [GET /*] — serve a static file from the activeStaticFilesworker bean.headStaticFile(RestRequest req, String path, Locale locale) [HEAD /*] — return GET headers for a static file without the body.Methods inherited from class org.apache.juneau.rest.server.servlet.RestServlet
builder, createAuthenticator, destroy, doLog, getContext, getPath, getPaths, getRequest, getResponse, getRestBuilder, init, log, log, service, setContextMethods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPatch, doPost, doPut, doTrace, getLastModified, isSensitiveHeader, serviceMethods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Constructor Details
-
StaticFilesServlet
public StaticFilesServlet()
-
-
Method Details
-
getStaticFile
[GET /*] — serve a static file from the activeStaticFilesworker bean.- Parameters:
req- The current REST request — suppliesRestContext.getStaticFiles().path- The trailing remainder after the mount prefix.locale- The request locale (used for localized resource lookups).- Returns:
- The matching
HttpResource(with content type + cache headers). - Throws:
NotFound- If no resource matches the requested path.
-
headStaticFile
[HEAD /*] — return GET headers for a static file without the body.- Parameters:
req- The current REST request — suppliesRestContext.getStaticFiles().path- The trailing remainder after the mount prefix.locale- The request locale (used for localized resource lookups).- Returns:
- The matching
HttpResource(with headers; body suppressed by the processor). - Throws:
NotFound- If no resource matches the requested path.
-