= helloworld-html5: HTML5 and REST Hello World Example
:author: Jay Balunas, Burr Sutter, Douglas Campos, Bruno Olivera
:productName: WildFly
:productNameFull: WildFly Application Server
:jbossHomeName: WILDFLY_HOME
:productVersion: 12
:buildRequirements: Java 8.0 (Java SDK 1.8) or later and Maven 3.3.1 or later
include::../shared-doc/attributes.adoc[]

:level: Beginner
:technologies: CDI, JAX-RS, HTML5
:source: {githubRepoUrl}

[abstract]
The `helloworld-html5` quickstart demonstrates the use of CDI 1.2 and JAX-RS 2.0 using the HTML5 architecture and RESTful services on the backend.

:standalone-server-type: default
:archiveType: war

== What is it?

The `helloworld-html5` quickstart demonstrates the use of CDI 1.2 and JAX-RS 2.0 in {productNameFull} {productVersion} or later using the HTML5 + REST architecture.

The application is basically a smart, HTML5, CSS3, and JavaScript front-end using RESTful services on the backend.

* `HelloWorld.java`: Establishes the RESTful endpoints using JAX-RS.
* `web.xml`: Maps RESTful endpoints to `/hello`.
* `index.html`: Is a jQuery augmented plain old HTML5 web page.

The example can be deployed using Maven from the command line or from Eclipse using JBoss Tools.

//*************************************************
// Add System Requirements
//*************************************************
// == System Requirements
include::../shared-doc/system-requirements.adoc[leveloffset=+1]

// Additional requirements for this quickstart.
An HTML5 compatible browser such as Chrome, Safari 5+, Firefox 5+, or IE 9+ is required.

With the prerequisites out of the way, you are ready to build and deploy.

//*************************************************
// Add Use of JBoss Home Name
//*************************************************
// == Use of {jbossHomeName}
include::../shared-doc/use-of-jboss-home-name.adoc[leveloffset=+1]

//*************************************************
// Start the server with the default profile
//*************************************************
// == Start the {productName} Standalone Server
// include::../shared-doc/start-the-standalone-server.adoc[leveloffset=+1]
include::../shared-doc/start-the-standalone-server.adoc[leveloffset=+1]

//*************************************************
// Build and deploy the quickstart WAR
//*************************************************
// == Build and Deploy the Quickstart
include::../shared-doc/build-and-deploy-the-quickstart.adoc[leveloffset=+1]

== Access the Application

The application will be running at the following URL http://localhost:8080/{artifactId}/.

You can also test the REST endpoint by sending an HTTP `POST` request to the URLs below. Replace `__YOUR_NAME__` with a name of your choosing.

[discrete]
=== Test the XML Content

You can test The XML content by sending an HTTP `POST` to the following URL: http://localhost:8080/{artifactId}/hello/xml/__YOUR_NAME__

Type the following cURL command in terminal to issue the `POST` command:

[source,options="nowrap"]
----
curl -i -X POST http://localhost:8080/${project.artifactId}/hello/xml/__YOUR_NAME__
----

You will see the following response:

[source,options="nowrap"]
----
Connection: keep-alive
HTTP/1.1 200 OK
X-Powered-By: Undertow/1
Server: JBoss-EAP/7
Content-Type: application/xml
Content-Length: 44
Date: Tue, 13 Oct 2015 18:40:04 GMT

<xml><result>Hello YOUR_NAME!</result></xml>
----

[discrete]
=== Test the JSON Content

You can test the JSON content by sending an HTTP `POST` to the following URL: http://localhost:8080/{artifactId}/hello/json/__YOUR_NAME__

Type the following cURL command in terminal to issue the `POST` command:

[source,options="nowrap"]
----
curl -i -X POST http://localhost:8080/${project.artifactId}/hello/json/YOUR_NAME
----

You will see the following response:

[source,options="nowrap"]
----
HTTP/1.1 200 OK
Connection: keep-alive
X-Powered-By: Undertow/1
Server: JBoss-EAP/7
Content-Type: application/json
Content-Length: 29
Date: Tue, 13 Oct 2015 06:32:20 GMT

{"result":"Hello YOUR_NAME!"}
----

//*************************************************
// Undeploy the quickstart archive
//*************************************************
// == Undeploy the Quickstart
include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+1]

//*************************************************
// Run the Arquillian functional tests
//*************************************************
// == Run the Arquillian Functional Tests
include::../shared-doc/run-arquillian-functional-tests.adoc[leveloffset=+1]

//*************************************************
// Add JBoss Developer Studio instructions
//*************************************************
// == Run the Quickstart in Red Hat JBoss Developer Studio or Eclipse
include::../shared-doc/run-the-quickstart-in-jboss-developer-studio.adoc[leveloffset=+1]

//*************************************************
// Deploy the quickstart to OpenShift
//*************************************************
// == Deploy the Quickstart to OpenShift Online
include::../shared-doc/deploy-to-openshift-online.adoc[leveloffset=+1]

== Debug the Application

If you want to debug the source code or look at the Javadocs of any library in the project, run either of the following commands to pull them into your local repository. The IDE should then detect them.

[source,options="nowrap"]
----
$ mvn dependency:sources
$ mvn dependency:resolve -Dclassifier=javadoc
----
