The Embedded JSP plugin allows you to use JSPs from the classpath (from jar files).


JSPs are usually served from the file system. Using this plugin you can deploy JSPs inside jar files, which is sometimes desired, like when writing a plugin.


The plugin containes a modified version of Jasper 6, which reads JSPs from the classpath, and generates the java code in memory (no .java file is written). The Java Compiler API is then used to compile the java source code into bytecode (in memory, no .class file is generated), and it is turned into a Servlet, which is cached for future use.

About includes

Because the JSP files are read from the classpath, "includes" work differently than they do from the file system. Assume you want to include "Hello.jsp", when searching for that file in the classpath, multiple files might be found on different jars, like somejar.jar!/Hello.jsp and otherjar.jar!/Hello.jsp. That's why relative paths do not work in this plugin. Instead, create directory structures for the JSPs. For example, given 2 jsps under org/myexample/jsps in a jar file:


Hello there, I am the Doctor.


<jsp:include page="org/myexample/jsps/Who.jsp" />


 <package name="example" namespace="/example" extends="embeddedjsp-default">
     <action name="HelloWorld" class="example.HelloWorld">
         <result type="embeddedJsp">org/myexample/jsps/Hello.jsp</result>


  1. Java 6 or later


Tested with Tomcat 6.0.20.


This plugin requires Jetty 7 to work. And the Tomcat libraries must be deployed with the application, adding this to your pom.xml should take care of that:


To use Jetty 7 with the maven plugin add this to your pom.xml:

  • No labels

1 Comment

  1. Anonymous

    This plugin won't work with tomcat 7.0