Chapter 2. A taste of Scalatra
This chapter covers
- Understanding the framework’s major features
- A brief introduction to the concept of routing
- Sending parameters to a Scalatra application
As an introduction to building applications with Scalatra, let’s start with a basic page-retrieval system and then move on to more-advanced functionality. Because it’s your first app, we’ll keep the initial requirements fairly simple. You want to be able to visit URLs in the browser, retrieve data from a data store, format the data into styled HTML, and display the page. These are the sorts of common tasks that can be accomplished by pretty much any web framework. In this case, you’ll build a site that displays food-related text.
Let’s try generating a Scalatra application. Scalatra code generation is handled by a utility called g8, which grabs application templates from the internet, customizes them, and saves them on disk for you. To use g8, type the following on the command line: