Class ViewServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
- Direct Known Subclasses:
FreemarkerServlet,JspServlet,MustacheServlet,ThymeleafServlet
Each per-engine bridge module (juneau-rest-server-view-jsp,
juneau-rest-server-view-freemarker, juneau-rest-server-view-mustache,
juneau-rest-server-view-thymeleaf) ships a thin Basic*Servlet subclass that:
- Declares its own sibling top-level mount via
@Rest(paths)(e.g."/jsp/*"), so the servlet is registered as a sibling of the host application's other servlets (/rest/*,/jsp/*, ...) rather than composed under a host root. - Supplies the per-engine
RawTemplateDispatcher(the matching flavor-neutral<Engine>Dispatcherworker) viadispatcher().
The single greedy op declared here (@RestGet(path="/*")) captures the trailing remainder
under the servlet's mount and delegates straight to the shared RawTemplateDispatcher.
Because the mixin and standalone forms both route through the same RawTemplateDispatcher
implementation, their raw file-serving behavior cannot drift.
Standalone vs mixin:
The mixin Basic*Resource keeps its op pinned at /<token>/* for composition into a
host at /; the standalone Basic*Servlet moves the mount to the class level
(@Rest(paths="/<token>/*")) and pins the op at /*, eliminating the path-doubling
that a mixin-shaped op would otherwise produce when the servlet itself is mounted at
/<token>/*.
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 TypeMethodDescriptionprotected abstract RawTemplateDispatcherReturns the per-engineRawTemplateDispatcherthis servlet delegates raw template dispatch to.voidrender(String path, RestRequest req, RestResponse res) [GET /*] — render the raw template identified by the trailing path under this servlet's sibling top-level mount.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
-
ViewServlet
public ViewServlet()
-
-
Method Details
-
dispatcher
Returns the per-engineRawTemplateDispatcherthis servlet delegates raw template dispatch to.Typically the matching flavor-neutral
<Engine>Dispatcherworker (which implementsRawTemplateDispatcher). Nevernull.- Returns:
- The raw-template dispatcher. Never
null.
-
render
[GET /*] — render the raw template identified by the trailing path under this servlet's sibling top-level mount.The
@Path("/*") String pathcaptures the multi-segment remainder after the mount prefix (e.g. a request for/jsp/admin/dashboard.jspon a servlet mounted at/jsp/*matches withpath = "admin/dashboard.jsp"). Delegates verbatim to the sharedRawTemplateDispatcher.- Parameters:
path- The trailing path segment after the mount prefix.req- The current REST request.res- The current REST response.- Throws:
IOException- If the underlying response writer fails.
-