Package org.apache.juneau.rest.server.view.jsp


package org.apache.juneau.rest.server.view.jsp
JSP view-rendering bridge — opt-in juneau-rest-server-view-jsp module.

Provides three sibling pieces that together let a Juneau REST resource render JSP templates:

  • JspMixin — mixin that serves raw .jsp resources from the importer's classpath under /jsp/*.
  • JspView — immutable value class (implements the core View interface) returned from @RestOp methods to ask the framework to render a JSP.
  • JspViewRenderer — ResponseProcessor that detects JspView returns and dispatches via ServletContext.getRequestDispatcher(...).forward(...).

Note: by default a host's own @RestOp methods only see the host's own @Rest(responseProcessors=...) chain — a mixin's contributed processors apply only to the mixin's own endpoints (e.g. JspMixin's /jsp/* route), not to the host's. To have the host's own @RestOp methods dispatch JspView returns through the JSP engine, the host opts in via @Mixin(mergeIntoHost=true) (recommended — folds JspMixin's responseProcessors into the host's own chain, see the example below), or alternatively lists JspViewRenderer.class explicitly in its own @Rest(responseProcessors=...).

Composition example (microservice):

@Rest(path="/app", mixinDefs=@Mixin(type=JspMixin.class, mergeIntoHost=true)) public class AppResource extends RestServlet { @Bean JspMixin jsp() { return JspMixin.create() .basePath("/WEB-INF/views/") .build(); } @RestGet("/hello/{name}") public View hello(@Path String name) { return JspView.of("hello.jsp").attr("name", name); } }

Engine-agnostic packaging:

The bridge module's main POM declares only the JSP API + JSTL impl in provided scope — no JSP engine ships here. Consumers add the engine matching their container:

  • Jetty 12 EE11 (microservice-jetty, Spring Boot embedded Jetty): org.eclipse.jetty.ee11:jetty-ee11-apache-jsp.
  • Embedded Tomcat (Spring Boot default): org.apache.tomcat.embed:tomcat-embed-jasper.
  • External-WAR deployments (Tomcat / JBoss / WildFly): engine is already on the container's classpath; no additional dependency required.

When no engine is on the classpath, the renderer surfaces a clear diagnostic naming the missing dependency and linking to the "Choosing a JSP engine" matrix in JspViewSupport.md.

See Also:
Since:
10.0.0