include::../shared-doc/attributes.adoc[]

= helloworld-html5: HTML5 and REST Hello World Example
:author: Jay Balunas, Burr Sutter, Douglas Campos, Bruno Olivera
:level: Beginner
:technologies: CDI, JAX-RS, HTML5

[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.

//*************************************************
// Product Release content only
//*************************************************

ifndef::EAPCDRelease[]

// 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.

// Use of {jbossHomeName}
include::../shared-doc/use-of-jboss-home-name.adoc[leveloffset=+1]
// Start the {productName} Standalone Server
include::../shared-doc/start-the-standalone-server.adoc[leveloffset=+1]
// 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
include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+1]
// Run the Arquillian Functional Tests
include::../shared-doc/run-arquillian-functional-tests.adoc[leveloffset=+1]
// Run the Quickstart in Red Hat JBoss Developer Studio or Eclipse
include::../shared-doc/run-the-quickstart-in-jboss-developer-studio.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
----

endif::[]

//*************************************************
// CD Release content only
//*************************************************

ifdef::EAPCDRelease[]

// Getting Started with OpenShift
include::../shared-doc/cd-openshift-getting-started.adoc[leveloffset=+1]
//Prepare OpenShift for Quickstart Deployment
include::../shared-doc/cd-create-project.adoc[leveloffset=+1]
// Import the Latest {xpaasproduct-shortname} Image Streams and Templates
include::../shared-doc/cd-import-imagestreams-templates.adoc[leveloffset=+1]
// Deploy the {ProductShortName} Source-to-Image (S2I) Quickstart to OpenShift
include::../shared-doc/cd-deploy-project.adoc[leveloffset=+1]
// OpenShift Post Deployment Tasks: This is not currently needed.
// include::../shared-doc/cd-post-deployment-tasks.adoc[leveloffset=+1]

endif::[]
