Play for Java: Covers Play 2
Summary

Play for Java shows you how to build Java-based web applications using the Play 2 framework. The book starts by introducing Play through a comprehensive overview example. Then, you'll look at each facet of a typical Play application, both by exploring simple code snippets and by adding to a larger running example. Along the way, you'll contrast Play and JEE patterns and learn how a stateless web application can fit seamlessly in an enterprise environment.

About the Book

For a Java developer, the Play web application framework is a breath of fresh air. With Play you get the power of Scala's strong type system and functional programming model, and a rock-solid Java API that makes it a snap to create stateless, event-driven, browser-based applications ready to deploy against your existing infrastructure.

Play for Java teaches you to build Java-based web applications using Play 2. This book starts with an overview example and then explores each facet of a typical application by discussing simple snippets as they are added to a larger example. Along the way, you'll contrast Play and JEE patterns and learn how a stateless web application can fit seamlessly in an enterprise Java environment. You'll also learn how to develop asynchronous and reactive web applications.

The book requires a background in Java. No knowledge of Play or of Scala is assumed.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

What's Inside
  • Build Play 2 applications using Java
  • Leverage your JEE skills
  • Work in an asynchronous way
  • Secure and test your Play application

About the Authors

Nicolas Leroux is a core developer of the Play framework. Sietse de Kaper develops and deploys Java-based Play applications.

Table of Contents
  1. An introduction to Play
  2. The parts of an application
  3. A basic CRUD application
  4. An enterprise app, Play-style
  5. Controllers—handling HTTP requests
  6. Handling user input
  7. Models and persistence
  8. Producing output with view templates
  9. Asynchronous data
  10. Security
  11. Modules and deployment
  12. Testing your application
"1114875088"
Play for Java: Covers Play 2
Summary

Play for Java shows you how to build Java-based web applications using the Play 2 framework. The book starts by introducing Play through a comprehensive overview example. Then, you'll look at each facet of a typical Play application, both by exploring simple code snippets and by adding to a larger running example. Along the way, you'll contrast Play and JEE patterns and learn how a stateless web application can fit seamlessly in an enterprise environment.

About the Book

For a Java developer, the Play web application framework is a breath of fresh air. With Play you get the power of Scala's strong type system and functional programming model, and a rock-solid Java API that makes it a snap to create stateless, event-driven, browser-based applications ready to deploy against your existing infrastructure.

Play for Java teaches you to build Java-based web applications using Play 2. This book starts with an overview example and then explores each facet of a typical application by discussing simple snippets as they are added to a larger example. Along the way, you'll contrast Play and JEE patterns and learn how a stateless web application can fit seamlessly in an enterprise Java environment. You'll also learn how to develop asynchronous and reactive web applications.

The book requires a background in Java. No knowledge of Play or of Scala is assumed.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

What's Inside
  • Build Play 2 applications using Java
  • Leverage your JEE skills
  • Work in an asynchronous way
  • Secure and test your Play application

About the Authors

Nicolas Leroux is a core developer of the Play framework. Sietse de Kaper develops and deploys Java-based Play applications.

Table of Contents
  1. An introduction to Play
  2. The parts of an application
  3. A basic CRUD application
  4. An enterprise app, Play-style
  5. Controllers—handling HTTP requests
  6. Handling user input
  7. Models and persistence
  8. Producing output with view templates
  9. Asynchronous data
  10. Security
  11. Modules and deployment
  12. Testing your application
49.99 In Stock
Play for Java: Covers Play 2

Play for Java: Covers Play 2

Play for Java: Covers Play 2

Play for Java: Covers Play 2

Paperback(1st Edition)

$49.99 
  • SHIP THIS ITEM
    Qualifies for Free Shipping
  • PICK UP IN STORE
    Check Availability at Nearby Stores

Related collections and offers


Overview

Summary

Play for Java shows you how to build Java-based web applications using the Play 2 framework. The book starts by introducing Play through a comprehensive overview example. Then, you'll look at each facet of a typical Play application, both by exploring simple code snippets and by adding to a larger running example. Along the way, you'll contrast Play and JEE patterns and learn how a stateless web application can fit seamlessly in an enterprise environment.

About the Book

For a Java developer, the Play web application framework is a breath of fresh air. With Play you get the power of Scala's strong type system and functional programming model, and a rock-solid Java API that makes it a snap to create stateless, event-driven, browser-based applications ready to deploy against your existing infrastructure.

Play for Java teaches you to build Java-based web applications using Play 2. This book starts with an overview example and then explores each facet of a typical application by discussing simple snippets as they are added to a larger example. Along the way, you'll contrast Play and JEE patterns and learn how a stateless web application can fit seamlessly in an enterprise Java environment. You'll also learn how to develop asynchronous and reactive web applications.

The book requires a background in Java. No knowledge of Play or of Scala is assumed.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

What's Inside
  • Build Play 2 applications using Java
  • Leverage your JEE skills
  • Work in an asynchronous way
  • Secure and test your Play application

About the Authors

Nicolas Leroux is a core developer of the Play framework. Sietse de Kaper develops and deploys Java-based Play applications.

Table of Contents
  1. An introduction to Play
  2. The parts of an application
  3. A basic CRUD application
  4. An enterprise app, Play-style
  5. Controllers—handling HTTP requests
  6. Handling user input
  7. Models and persistence
  8. Producing output with view templates
  9. Asynchronous data
  10. Security
  11. Modules and deployment
  12. Testing your application

Product Details

ISBN-13: 9781617290909
Publisher: Manning
Publication date: 03/31/2014
Edition description: 1st Edition
Pages: 320
Product dimensions: 7.30(w) x 9.10(h) x 0.90(d)

About the Author

Nicolas Leroux is Technical Director at Lunatech Research in The Netherlands and is a core developer of the Play framework. Nicolas is also a frequent speaker at conferences where he introduces Play to the audience.

Sietse de Kaper, a software developer at Lunatech, has been developing and deploying Java-based Play applications since version 1.0. Having had the opportunity to use Play for several projects, he considers it the most effective framework in the Java ecosystem.

Table of Contents

foreword xiii

preface xv

acknowledgments xvii

about this book xix

Part 1 Introduction and first steps 1

1 An introduction to Play 3

1.1 What Play is 4

Key features 4

Java and Scala 5

Play is not Java EE 6

1.2 High-productivity web development 6

Working with HTTP 6

Simplicity, productivity, and usability 7

1.3 Reactive programming 7

Event-driven 7

Scalable 8

Resilient 8

Responsive 8

1.4 Play 2 enterprise features 8

Simplicity 8

Traditional data access 9

Flexibility 9

Integration 9

Large-team applications 9

Security 9

Modularity 10

1.5 Hello Play! 10

Installing Play 10

Creating your first application 12

Play application structure 13

Running the application 13

Accessing the running application 14

Changing the controller class 14

Add a compilation error 16

Use an HTTP request parameter 16

Add an HTNIL page template 17

1.6 The console 18

1.7 Summary 19

2 The parts of an application 21

2.1 Introducing our application 22

2.2 A rundown of a Play application 22

2.3 Play's configuration files 23

2.4 Build configuration files 25

2.5 Public assets 26

2.6 Application code 27

Compiled assets 28

2.7 Setting up an IDE 29

Eclipse 29

NetBeans 30

IntelliJ IDEA 34

Using a debugger 34

2.8 Summary 36

3 A basic CRUD application 37

3.1 Adding a controller and actions 38

3.2 Mapping URLs to action methods using routes 39

3.3 Adding a model and implementing functionality 40

Creating a model class 40

3.4 Mocking some data 41

3.5 Implementing the list method 43

The list template 43

3.6 Adding the product form 47

Constructing the form object 48

Rendering the HTML form 48

Rendering input fields 49

3.7 Handling the form submission 50

3.8 Adding a delete button 53

3.9 Summary 55

Part 2 Core functionality 57

4 An enterprise app, Play-style 59

4.1 Recalling what an enterprise application is 59

4.2 Determining today's enterprise application challenges 63

4.3 Understanding Play's application in an enterprise context 64

4.4 Defining our warehouse enterprise application 68

4.5 Summary 70

5 Controllers-handling HTTP requests 72

5.1 Controllers and action methods 73

Action methods 74

Examining our controller 74

5.2 Returning results from action methods 75

Results 76

Redirect result 77

Using results 77

5.3 Using routing to wire URLs to action methods 80

Translating HTTP to Java code 80

The routes files explained 83

Dynamic path parts 84

Completing our routes file 87

Reverse routing 88

5.4 Interceptors 89

The @With annotation 89

Explaining our CatchAction 91

Action composition 91

5.5 About scopes 93

A bit of history about the scopes 93

Storing data with Play 94

The context object 95

The request scope 96

The response scope 96

The session scope 97

The flash scope 98

What about security? 99

5.6 Summary 101

6 Handling user input 102

6.1 Forms 102

Displaying the new product form 103

Displaying the edit product form 105

Processing form input 107

6.2 Data binding 108

Binding single values 109

Binding multiple values 110

Custom data binders and formatters 114

6.3 Body parsers 123

The body-parser API 124

6.4 Validation 126

Using the built-in validators 126

Partial validation 128

Creating a custom validator 129

Displaying the validation errors on the form 132

6.5 File uploads 134

6.6 Summary 137

7 Models and persistence 138

7.1 Modeling the real world in code 139

The reasons for getters and setters 139

Let Play eliminate some noise for you 141

Creating our classes 142

7.2 Persistence and Object-Relational Mapping (ORM) 143

About relational databases 143

Bridging the relational world and the OO world 144

Introducing Ebean 145

7.3 Mapping basic entities 145

Configuring Ebean and the database 146

Inspecting the H2 database 148

Saving our first entities 149

7.4 Mapping relationships 151

Mapping a one-to-many relationship 152

Making the one-to-many relationship bidirectional 154

Giving our warehouse an address 156

Mapping the product-tag relationship 159

7.5 Querying for objects 161

Retrieving by ID 162

Using the Finder API 162

Loading initial data 166

Creating more complex queries 168

7.6 Using JPA instead of Ebean 173

Configuring Play 173

Adding Persistence.xml 174

Built-in JPA helpers 175

7.7 Summary 175

8 Producing output with view templates 177

8.1 The benefits of compiled, type-safe templates 178

8.2 Scala template syntax 181

Template definition 181

Template body 181

Expression scope 183

8.3 Your basic building blocks 184

Iterating 184

Making decisions 186

8.4 Structuring pages with template composition 187

Includes 187

Layouts 193

8.5 Using LESS and CoffeeScript: the asset pipeline 199

LESS 199

CoffeeScript 200

The asset pipeline 201

8.6 Internationalization 202

Configuration and message files 202

Using messages in your application 203

8.7 Summary 204

Part 3 Advanced Topics 205

9 Asynchronous data 207

9.1 What do we mean by asynchronous data? 208

9.2 Handling asynchronous data 209

Handling asynchronous requests 210

Returning the asynchronous result 212

9.3 Scheduling asynchronous tasks 214

9.4 Streaming HTTP responses 215

Standard responses and Content-Length header 215

Serving files 216

Chunked responses 217

9.5 Unidirectional communication with Comet 220

9.6 Bidirectional communication with WebSockets 223

WebSockets explained 224

A more advanced application with WebSockets 227

9.7 Summary 231

10 Security 232

10.1 Play security concepts 232

Play 2 session 233

Cross-site scripting 234

SQL injection 235

Cross-site request forgery 235

10.2 Adding basic authentication with filters 238

10.3 Fine-grained authentication with action composition 243

10.4 Summary 248

11 Modules and deployment 249

11.1 Modules 249

Using modules 250

Creating modules 254

11.2 Splitting your application into multiple sub-applications 260

11.3 Deploying to production 262

Packing up your application 263

Working with multiple configurations 263

Creating native packages for a package manager 265

Setting up a front-end proxy 266

Using SSL 268

Deploying to a cloud provider 269

Deploying to application server 270

11.4 Summary 270

12 Testing your application 271

12.1 Testing Play applications 272

Writing tests 272

Running tests 273

12.2 Functional testing 276

Testing your controllers 276

Template testing 278

Testing the router 281

12.3 Integration testing 282

Testing your HTTP interface 282

Browser testing 283

12.4 Summary 286

index 289

From the B&N Reads Blog

Customer Reviews