Class JspViewRenderer
- All Implemented Interfaces:
ResponseProcessor,ViewRenderer
ResponseProcessor that detects JspView-typed return values and dispatches them
to the underlying JSP engine via
ServletContext.getRequestDispatcher(...).forward(...).
Auto-registered by JspMixin via
@Rest(responseProcessors=...)
— callers who add the mixin don't need to wire up this class explicitly. Callers who want
to handle JspView returns without adopting the mixin (e.g. mounting their own
raw-JSP path) can add this class to their own
responseProcessors list.
Behavior:
- Inspect the response content. If the value is not a
JspView, returnNEXTso the rest of the chain runs (the standard POJO serializer / plain-text fallback handle non-JspViewreturns). - Read the active
JspMixinfrom theRestContextbean store to discover the configured base path; fall back to"/"when none is registered (a caller using the renderer standalone without the mixin). - Copy every entry from
JspView.getAttributes()onto the request as a request attribute viareq.setAttribute(...)so the JSP / JSTL EL pipeline can resolve them. - Apply every entry from
JspView.getResponseHeaders()viares.setHeader(...). - Obtain the underlying
ServletContext,getRequestDispatcher(basePath + templateName), and callforward(...). - When no JSP engine is on the classpath, the dispatcher returns
null(or forward fails withClassNotFoundException). Surface a human-readable diagnostic naming the missing dependency and linking to the "Choosing a JSP engine" matrix.
Note on forward():
forward() resets the response output stream.
If a @RestPreCall hook has already
written response headers/body before the renderer runs, the forward may fail or produce
malformed output. The renderer runs at response-resolution time so this is rarely hit by
accident; document the constraint for any user relying on RestPreCall.
See Also:
- Since:
- 10.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDiagnostic message emitted when no JSP engine can be found on the classpath at forward-time.Fields inherited from interface org.apache.juneau.rest.server.processor.ResponseProcessor
FINISHED, NEXT, RESTART -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintprocess(RestOpSession opSession) Process this response if possible.
-
Field Details
-
NO_ENGINE_DIAGNOSTIC
Diagnostic message emitted when no JSP engine can be found on the classpath at forward-time.Public so tests and consumer apps can pattern-match against the message text without depending on internal string literals.
- See Also:
-
-
Constructor Details
-
JspViewRenderer
public JspViewRenderer()
-
-
Method Details
-
process
Description copied from interface:ResponseProcessorProcess this response if possible.- Specified by:
processin interfaceResponseProcessor- Parameters:
opSession- The HTTP call.- Returns:
- One of the following codes:
0 - The processor could not handle the request.1 - The processor was able to fully handle the request.2 - The processor was able to partially handle the request by replacing the output. The response processors should start over.
- Throws:
IOException- If low-level exception occurred on output stream.
Results in aHttpServletResponse.SC_INTERNAL_SERVER_ERRORerror.BasicHttpException- If some other exception occurred.
Can be used to provide an appropriate HTTP response code and message.
-