Scala Pages

Download Current version: 0.2.0 (for Scala 2.8.x and higher) Download Manual (PDF)

Older Versions

Scala Pages 0.1.1 (Scala 2.7.7)
Scala Pages 0.1.2

What are Scala Pages?

Scala Pages (SCP) is a lightweight framework for creating Scala web applications. It is itself written in Scala and released under the Apache 2 license. SCP provides an API that is familiar to Java programmers, as it is built on and closely aligned to the Servlet API.  It can be learned quickly by anyone familiar with Java web development. The SCP Scala web framework is build around a text-oriented template engine and facilitates an MVC application architecture. Templates can be HTML-templates, XML-templates or any other text format, such as CSV, JSON, etc. SCP is designed to be fast, efficient, and scalable with moderate CPU and memory requirements.

Target Audience

Scala Pages likely appeals to web programmers who come from a Java background and want to program web applications in Scala.


  • Adheres to model-view-controller (MVC) paradigm
  • Text-based template engine
  • Simple syntax: $variable and <?scp-instruction?>
  • Encoding/content detection, able to handle international text encodings
  • Template processing instructions are extensible with snippet classes
  • URL Rewriting
  • Template Caching

Code Sample

The following example contains a response class (= page controller) that picks a random colour and a template that displays the chosen colour. The resulting page will look different upon each refresh:

import scala.util.Random
import scp.core._

class WebPage(request: Request) extends TemplateResponse(request) {
  override def controller: Unit = {
    val colours = List(
    ("greenish", "#33cc66"),
    ("blueish", "#3399ff"),
    ("redish", "#cc3300"),
    ("shocking pink", "#ff00cc"),
    ("light purple", "#996699"),
    ("baby blue", "#66ffcc"),
    ("yellowish", "#fff33")
  val pick = colours(Random.nextInt(6))
  request.vars += "nameOfColour" -> pick._1
  request.vars += "colour" -> pick._2

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    <title>Colour Example</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <h1 style="color:$colour">This ought to be $nameOfColour</h1>