/jboss-eap-hello-5

Primary LanguageHTMLOtherNOASSERTION

../shared-doc/attributes.adoc

helloworld-html5: HTML5 and REST Hello World Example

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.

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.

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.

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.

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:

curl -i -X POST http://localhost:8080/${project.artifactId}/hello/xml/__YOUR_NAME__

You will see the following response:

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>

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:

curl -i -X POST http://localhost:8080/${project.artifactId}/hello/json/YOUR_NAME

You will see the following response:

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!"}

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.

$ mvn dependency:sources
$ mvn dependency:resolve -Dclassifier=javadoc