
Develop RESTful Java web services with JAX-RS and Jersey by building an address book REST endpoint, tested with Postman, and learn core concepts from setup through deployment.
Explore JAX-RS, Java API for RESTful web services, using annotations to map Java classes to resources and enable content negotiation with produces and consumes for JSON and XML, via Jersey.
Here are the direct links for the download pages:
JDK: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Eclipse: https://www.eclipse.org/downloads/packages/release/mars/r/eclipse-ide-java-ee-developers
Apache Tomcat: http://mirrors.estointernet.in/apache/tomcat/tomcat-9/v9.0.16/bin/apache-tomcat-9.0.16.zip
Create a new Maven web project in Eclipse, configure group and artifact IDs and Java 8, add a deployment descriptor, and run on Tomcat to view the home page.
Learn how to produce different representations from a web service using content negotiation, mapping accept headers to text/plain and application/json outputs in a Jersey-based JAX-RS resource.
Demonstrates importing a database table and data into the project database, including unzipping the dataset, locating the file, running and connecting to the database, and importing up to 1000 records.
Develop a dao interface and a jdbc-based implementation for managing contacts, including an entity with fields and getters/setters, and a connection utility that reads db settings from a properties file.
Implement the addContact() method by inserting a contact via a prepared statement, capture and assign the generated primary key, and return the updated contact using try-with-resources.
Implement the updateContact() method using a prepared update statement with seven parameters, execute it, and return the affected row count; throw an exception if no records update.
implement delete contact using a prepared sql delete from contacts where id = ? with a try-with-resources block, handle exceptions, and return a message based on the row count.
Implement find methods using prepared statements for select queries, map results to contact objects, and refactor shared logic into a private helper for find by city, country, or all.
Create a dao factory to decouple the web service interface from gbc and hibernate implementations. Make the factory final with a private constructor and a switch-based selection.
Create a Jersey REST endpoint to handle GET requests and return JSON for all contacts or a specific contact by id, using path and query parameters.
Learn to handle post requests to create a new resource in a RESTful Java web service using JAX-RS and Jersey by consuming JSON, mapping with Jackson, and persisting a contact.
Update a contact resource using the put method in a RESTful Java service with JAX-RS and Jersey, sending a JSON payload to modify email and city and receive updated data.
Explain how to implement a JAX-RS delete endpoint to remove a contact by id, returning 200 ok for successful deletes and handling invalid ids and exceptions.
Map thrown exceptions to a custom JSON error response in restful services, including an error message and timestamp, and return a meaningful HTTP status code.
Develop a custom MessageBodyWriter provider to serialize Contact objects (and lists) to CSV text, implementing isWriteable, getSize, and writeTo to output header and data lines.
Showcases a MessageBodyReader that converts CSB data into a contact object during a post request, reading from an input stream and parsing comma-separated fields to persist to the database.
Implement a servlet filter to enable cross-origin resource sharing (CORS) for RESTful Java web services, adding access-control headers (origin, methods, headers) to allow cross-origin requests to /api/contacts.
Export a war file from Eclipse for deployment on a Tomcat server using the export wizard. Verify contents with jar tf to confirm web content, classes, and dependencies.
Deploy a restful Java web service on a locally installed Apache Tomcat by hard deploying the war into Tomcat's webapps folder. Start Tomcat and confirm endpoints like /api/hello and /api/1.
JAX-RS the Java API for RESTful Web Services is a Java programming language API specification that provides support in creating web services according to the Representational State Transfer (REST) architectural pattern. JAX-RS uses annotations, introduced in Java SE 5, to simplify the development and deployment of web service clients and endpoints.
From version 1.1 on, JAX-RS is an official part of Java EE 6. A notable feature of being an official part of Java EE is that no configuration is necessary to start using JAX-RS. For non-Java EE 6 environments a small entry in the web.xml deployment descriptor is required.
This course will guide you through the steps in creating powerful RESTful web services using the Java official API.
All the best!