Fauxjsp: productive JSP development

Important note: This post is not being updated. For up-to-date information refer to the project repository: https://github.com/ggeorgovassilis/fauxjsp/

About JSP

In this post I’ll present a new open source project I’m currently working on, fauxjsp [1] which re-implements JSP in a way that is more robust and faster for developers. It is intended for development, where it indeed is fast and leightweight compared to the standard implementation.
Java Server Pages (JSP) [2] is a stable, widely supported scripting technology for creating dynamic HTML pages which went out of fashion for various reasons: JSF, Web 2.0, yet I speculate that it would be more popular if people knew about tagfiles [3] which allow authoring of reusable components by writing JSP. Especially in modern Web 2.0 applications, JSP allows for very easy templating and UI construction while allowing at the same time dynamic configuration via MVC applications.

Developing JSP is slow

As far as I know, Tomcat’s Jasper [4] is the only JSP implementation – at least the only I ever worked with. Applications deployed into Tomcat receive Jasper automatically as a servlet named “jsp” to which all JSP pages are mapped. When a JSP page is requested (either directly by the browser or forwarded to by an MVC framework), Jasper:
  1. picks up the JSP file
  2. resolves any included code fragments, tagfiles and taglibraries
  3. generates Java source code
  4. compiles the Java source code to byte code
  5. loads the byte code
  6. renders the page by running the loaded code
In a production environment, highly optimized Java code resulting out of these steps renders web content fast and efficiently. However, during development every time a file is changed, Jasper will pull the changed files through these steps again, possibly repeating the ordeal for JSP dependencies. This becomes especially slow when the servlet container is restarted, which means that the JVM hasn’t “warmed” up Jasper yet.
A further problem arises from implementation glitches in the entire JSP-JSTL-Jasper-Tomcat chain which lead sooner or later during the development process to inexplainable compile errors, ClassNotFoundErrors, OutOfMemoryErrors, class loading frenzies and servlet container instabilities.

Speeding up JSP loading

Fauxjsp [1] is an open source JSP parser and renderer which simply interprets JSP and renders it on the spot, without going through Jasper’s compilation steps. While this obviously speeds up loading and rendering frequently changing JSPs, it is not suitable for production as every access to the page will parse it again, leading to slow response times and high CPU utilization.

Using it is quite straight forward:

  1. Check out the repository and build it
  2. Include dependencies into your web application
  3. Include the fauxjsp declaration in your web application’s web.xml:


There are several, more or less important deviations from Jasper’s implementation:

Taglibs are not supported directly. While discovering taglibs is a task of manageable complexity, rendering them is difficult because of the complex and implicit JSTL API. A few core taglibs have been directly hard-coded into the parser and more will probably follow. However using third-party taglibs in a JSP page will require custom development.

The parser is not as robust as Jasper: sneaky characters like “, in tag attributes can confuse the parser and thus their escaped forms &, < and > must be used where possible.
Scriptlets won’t work since that would require a slow source code compilation.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.