You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Name

Embedded JSP Plugin

Publisher

Apache Software Foundation

License

Open Source (ASL2)

Version

not released (Struts sandbox)

Homepage

this is it

Error formatting macro: rate: java.lang.NoSuchMethodError: 'java.lang.String com.atlassian.confluence.setup.BootstrapManager.getDomainName()'

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

Introduction

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.

Wait...what?

The plugin containes a modified version of Jasper 5, 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 a 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 render "Hello.jsp", when searching for that file in the classpath, multiple files might be found (on different jars). 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:

Who.jsp:

Hello there, I am the Doctor.

Hello.jsp:

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

Mapping:

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

Requirements

  1. Java 6 or later
  2. Install the plugin

Installing

$ svn co http://svn.apache.org/repos/asf/struts/sandbox/trunk/struts2-jsp-plugin struts2-jsp-plugin
$ cd struts2-jsp-plugin && mvn install

If you are using maven add this to your pom.xml:

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-jsp-plugin</artifactId>
    <version>2.1.8-SNAPSHOT</version>
</dependency>
  • No labels