JSP Convert

Ditch that crappy JSP pronto!

Overview

JSP Converter is a little tool for converting your legacy JSP / JSTL / JSP EL stuff into Scalate.

To use jsp2ssp you need to install the Scalate tool

Using jsp2ssp

To convert the JSP files in a directory foo just type

scalate foo

You should see lots of ssp files generated.

Known issues

Note that JSP Converter is not totally perfect; there are going to be JSP files that need a little bit of of manual tweaking. We've done our best to cover most of the common things to try reduce as much manual intervention as possible.

  • Any unknown custom tag (xml prefixed element) is listed on the console as a warning. Its easy to hack the JspConvert class if you want to add support for more JSTL or common custom tags. Most of the common JSTL tags are covered but we love contributions if you want to add more.
  • When converting expressions like foo.bar to the scala equivalent foo.getBar (since Scala is typesafe and doesn't use runtime reflection), we cannot detect boolean properties easily from JSP, so you might get some compile errors where foo.getBar needs to be changed to foo.isBar

Notes

Iterating over maps tends to be different in scala. In JSTL / EL you tend to iterate over a map which returns a Map.Entry object. In Scala you get a tuple of key and value. So instead of this…

#for (entry <- someMap)
  ${entry.getKey} = ${entry.getValue}
#end

A more idiomatic scala way would be

#for ((key, value) <- someMap)
  ${key} = ${value}
#end

Though we support the former JSTL/EL style by using an implicit conversion of a tuple to a MapEntry object which has a getKey and getValue method.The implicit conversion comes from the org.fusesource.scalate.util.TemplateConversions companion object.