Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Scala for Java Developers

You're reading from   Scala for Java Developers Build reactive, scalable applications and integrate Java code with the power of Scala.

Arrow left icon
Product type Paperback
Published in Apr 2014
Publisher
ISBN-13 9781783283637
Length 282 pages
Edition Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Thomas Alexandre Thomas Alexandre
Author Profile Icon Thomas Alexandre
Thomas Alexandre
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Scala for Java Developers
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
1. Programming Interactively within Your Project 2. Code Integration FREE CHAPTER 3. Understanding the Scala Ecosystem 4. Testing Tools 5. Getting Started with the Play Framework 6. Database Access and the Future of ORM 7. Working with Integration and Web Services 8. Essential Properties of Modern Applications – Asynchrony and Concurrency 9. Building Reactive Web Applications 10. Scala Goodies Index

Working with HTTP


As Scala can import and invoke Java classes as well as extend them, many of the Scala libraries available as part of the Scala ecosystem are only a thin layer on top of robust and mature Java libraries, to either provide additional features or simplify their usage by adding some syntactic sugar.

One such example is the Scala dispatch library (available at http://dispatch.databinder.net/Dispatch.html), a useful library to achieve HTTP interaction based on Apache's robust HttpClient. Let's run a little dispatch session in the REPL.

As dispatch is an external library; we first need to import it into our SBT project to be able to use it from the REPL console. Add the dispatch dependency to the build.sbt file of the SampleProject so that it looks like the following code snippet (make sure to have a blank line between statements in build.sbt):

name := "SampleProject"
…

libraryDependencies += "net.databinder.dispatch" %% "dispatch-core" % "0.11.0"

Restart the REPL to make the libraries...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime