Application Basics

Application Structure

A viable web application has several functional blocks: router, controllers, models, and views. The router accepts POST and GET requests and maps them to controllers. Controllers use models and utilities to perform business logic and respond to the request, often rendering views. Views rely on assets and references for images, scripts, and stylesheets.

In addition to the above, an application also has to be able to read configuration settings and perform some automated tasks.

...

When you created the project, Play Framework generated basic scaffolding for controllers, views, public assets, and configuration including routing. Some functionality, such as logging, error handling, and maintenance tasks, are included but not yet accessible. While working through the guide, you will be expanding framework’s functionality as well as adding utilities, models, and assets.

Application Secret

Application secret is a random string used by the Play Framework for signing session cookies, CSRF tokens, and encryption utilities. Please use a unique key for each of the environments: development, test, and production.

Using Terminal, generate a random hexadecimal key 56-characters long.

openssl rand -hex 56

Copy the key.

Using IntelliJ, expand conf directory and open application.conf.

Add a new entry:

Newkey is the new hexadecimal key.

Example: LineDrop Play/Scala Web Application - Configuration

Reference

Play Framework - Application Secret - 2.8.x

Session Cookie

Using IntelliJ, expand the conf directory and open application.conf.

Add a new entry:

Cookie_name is the name of your application’s session cookie. For example, at LineDrop we use the URL of the applications, such as code.LineDrop.io.

Example: LineDrop Play/Scala Web Application - Configuration

Reference

Play Framework - Settings Session - 2.8.x


Next: User Interface