Book Image

Java EE 7 Development with NetBeans 8

By : David R Heffelfinger
5 (1)
Book Image

Java EE 7 Development with NetBeans 8

5 (1)
By: David R Heffelfinger

Overview of this book

Table of Contents (18 chapters)
Java EE 7 Development with NetBeans 8
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Examining the WebSocket code using samples included with NetBeans


NetBeans includes a lot of example projects that we can use as the basis for our own projects. One particularly useful sample included with NetBeans is an Echo application that uses WebSockets to output some server data on the browser.

To create the sample project, go to File | New Project, select Java EE under Samples from Categories, and select Echo WebSocket (Java EE 7) from Projects.

In the next screen of the wizard, select a project location or accept the default location.

Click on Finish and the project is created.

The sample Echo application in action

Before looking at the generated source code, let's take a quick look at the sample Echo application in action. We can run it as usual by right-clicking on the project and selecting Run.

A few seconds after clicking on Run, the browser pops up and automatically runs the application.

The text Hello WebSocket! Is automatically prepopulated on the text input field. Clicking on the...