Skip to main content
Jump to: navigation, search


< MoDisco‎ | Components‎ | JSP
Revision as of 07:51, 7 September 2010 by (Talk | contribs)

Mailing ListForums
Help Wanted
Bug Day
Browse SourceProject Set File

JSP Metamodel

The Modisco JSP MetaModel inherits from the Modisco XML one : JSP Metamodel.png

The choice to extend the XML MetaModel was made because JSP script uses the same tag mechanism, attributes and comments, and is most of the time XML well formed

According to the "Java Server Pages Specifications Version 1.2", JSP content is divided into 4 categories :

  • JSP Scripts :
    • JSP Scriplet : <% int variable = 0;%>
    • JSP Expression : <%= variable %>
    • JSP Declaration : <%! int variable = 0; %>
  • JSP Actions : <myPrefix:myAction arg1="value" />
    • JSP Standard Action : <jsp:getProperty name="beanName" property="propertyNamef" />
  • JSP Directive : <%@ include file="myFilePath" %>
    • JSP TagLib : <%@ taglib prefix="myPrefix" uri="taglib/mytag.tld" %>
  • Comments : <%-- This is a JSP comment --%>

Source Repository

All of the source code is stored in a public source repository, which you can access at:

JSP Discoverer

User Manuel

The plug-in provides the user with a contextual menu to easily create JSP models.

By right-clicking on a JSP Project in the Eclipse Package Explorer view, you can quickly create the JSP model of your application (see next Figure).

Menus in Eclipse to create JSP model from source code

You can also select one or several files to create a model for each one of them

Menus in Eclipse to create JSP model from several files

Once launched, a progress bar will appear at the bottom of the window as soon as the operation begins. Depending on the size of your application, the reverse engineering process might take some time to complete (see next Figure).

Progress bar during model creation

At the end of the process, the newly created model files are added to the root of your project and are automatically opened in the default editor (see next Figure).

JSP model in the package explorer

.jspxmi files can be opened in the Sample Ecore Model Editor (see next Figure).

Sample Ecole Model Editor

They can also be opened in the MoDisco model browser (see next Figure).

Model Model Browser

Discovery Limitations

Because JSP language is used to generate some content, it can be placed almost anywhere in the file, which implies some limitations:

This is why the "isTagFragment : EBoolean" attribute was added. In fact, everything contained in a tag declaration, as in its body, is considered as a children of this tag. It is indeed necessary to be able to differentiate whether the JSP tag is used to generate the tag description, or its body.

Some ways of implementing JSP might cause some problems with the parser, especially for tag's attributes evaluation. What is expected to be found is some kind of syntax like :

name="value" or name='value' and even name=value

Sometimes we faced implementations like : <tag name=" <% if(condition){ %> value1" <% }else{ %> value2" <% } %> >

The parser finds the opening double quote for the attribute's value, then looks for the closing one.

Returned value will be: JSP Metamodel Limit 1.png with an exception raised on the last double quote, because '=' is expected.

Source Repository

All of the source code is stored in a public source repository, which you can access at:

Discoverer API

Each MoDisco discoverer responds to a normalized interface and can be called programmatically (see org.eclipse.gmt.modisco.infra.discoverymanager.Discoverer).

As an example, you may checkout the code from org.eclipse.gmt.modisco.jsp.discoverer.tests project.

JSP Generation

The goal of the JSP Generation plug-in is to allow JSP/Html code generation from a Java model


JSP Code Generation

This plug-in proposes Acceleo MTL modules for generating JSP/html files conforming to JSP models. There is only one template which generates thecode

JSP models are obtained with JSPDiscoverer component.

User Manual

A prerequisite is a JSP model. Please refer to the JSP Discoverer user manual.

To launch JSP generation

  • Checkout org.eclipse.gmt.modisco.jee.jsp.generation into the workspace from Eclipse SVN repository, and Create an Accelo launch configuration pointing to GenerateJsp java class, and specify the input model and target folder.


  • Add org.eclipse.gmt.modisco.jee.jsp.generation in your plugin dependencies and use the GenerateJsp main method with input model and target folder as parameters. The code should look like this :
   GenerateJsp jspGenerator = new GenerateJsp(URI.createFileURI("C:/.../my.javaxmi"),
       new File("C:/.../myOutputFolder"), new ArrayList<Object>());

Back to the top