HowToDoInJava

  • Python
  • Java
  • Spring Boot
  • Dark Mode

JAX-RS 2.0 Tutorials

JAX-RS 2.0 is a framework designed to help you write RESTful applications both on the client and server side. Below tutorials are build using RESTEasy framework.

Get more JAX-RS tutorials on Jersey and Dropwizard pages.

Hello world application

RESTEasy + JBOSS 7 Hello world application

Learn about most basic configuration needed to build a RESTful web application in JBOSS AS7.

RESTEasy + Tomcat Hello world application

Learn about minimum configuration needed to build a RESTful web application using Tomcat server.

REST clients

RESTful client using java.net package

Build restful client for consuming the restful apis using java.net package.

RESTEasy client example

Build restful client for consuming the restful apis using inbuilt jax-rs capabilities.

Apache HttpClient example

Build restful client for consuming the restful apis using apache http client framework.

Ajax/ JavaScript client Example

Learn to build resteasy ajax client

JAX-RS 2.0 client API example

JAX-RS 2.0 has brought lots of improvement over previous version. One of major improvement is client API which was completely missing in JAX-RS 1.0. Learn to use in this tutorial.

XML/JSON support

RESTEasy + JAXB xml example

Learn to marshal model objects in xml documents using JAXB and send them to client as server response

RESTEasy + Jettison json example

Learn to marshal model objects in json documents using Jettison and send them to client as server response

RESTEasy + Jackson JSON example

Learn to marshal model objects in json documents using Jackson and send them to client as server response

File Download/Upload

RESTEasy + File download example

This example shows the configuration and code needed to download various file formats using RESTful API

RESTEasy + File Upload + HttpClient pure java client example

Upload the file to server using pure java client

RESTEasy + File Upload + HTML form example

Upload the file to server using html form submission

Annotations usage and examples

JAX-RS @Path Regex based URI matching

Example of API path matching using @Path annotation. Some regular expression examples are also included.

Hateoas Implementation

RESTful web services HATEOAS example

Learn making RESTful web services with HATEOAS links enabled

JAX-RS Security

Basic authentication and authorization example using PreProcessorInterceptor

Implement security using PreProcessorInterceptor.

JAX-RS 2.0 RESTEasy 3.0.2.Final security example using ContainerRequestFilter

PreProcessorInterceptor and PostProcessorInterceptor are deprecated now. So from now on, use ContainerRequestFilter and ContainerReponseFilter. Learn to use them in this tutorial.

REST Security Guide

Knowledge of securing RESTful Web Services is as much important as to write them. It’s very important to write secure APIs to protect the business. But before starting to secure RESTful APIs, let’s understand what are our options as developers? What will be good fit for our usecase?

Request Validation

Custom html form validation using ajax

Build ajax powered html form validation functionality for your web page

Hibernate validator provider demo

Integrate hibernate bean validation capability to your RESTEasy APIs

Various Integrations

RESTful web services using Spring 3 mvc

Learn how to write RESTful web services using Spring 3 framework

Logging Support

RESTEasy + Log4j example

Demo configuration to add log4j logging support in RESTEasy application

RESTEasy + SLF4jexample

Demo configuration to add slf4j logging support in RESTEasy application

Best practices

Share context data using ResteasyProviderFactory

ResteasyProviderFacory can be proved very handy when you want to share some data in various layers of application without passing them as method parameters

Exception handling using custom exception mapper

Build custom exception mappers to handle application specific handling of various exceptions

Enable gzip compression content encoding

JAX-RS Resteasy has automatic GZIP decompression support. Learn to use it.

JAX-RS RESTEasy Cache control with ETag example

ETags or entity tags are useful HTTP headers which can help in building a super fast application by minimizing the server load on system. ETag is set to the response to the client so a client can use various control request headers such as If-Match and If-None-Match for conditional requests. javax.ws.rs.core.Response.ResponseBuilder#tag() and javax.ws.rs.core.EntityTag are useful classes to work on ETags.

Resources for RESTful Web services

  • Jboss RESTEasy home
  • JBoss Server
  • Tomcat Server
  • JAX-RS 2 Specs
  • Jettison Library
  • Jackson Library

Was this post helpful?

Let us know if you liked the post. That’s the only way we can improve.
TwitterFacebookLinkedInRedditPocket

Feedback, Discussion and Comments

  1. Ishank Tyagi

    August 7, 2020

    Are this tutorial valid in 2020?

    • Lokesh Gupta

      August 7, 2020

      Probably not. I am already in process of updating all tutorials in this blog. Thanks for your patience.

  2. suresh

    January 20, 2014

    very helpfull bro

  3. dilip

    December 22, 2013

    good post really helpful

  4. Venu

    December 9, 2013

    Can you please provide various ways of reading / posting big JSON data with RESTful webservices..

    • rajesh

      December 10, 2013

      what are you using for posting big JSON data on server side?
      which one are you used queryParam or pathparam in serverside.
      and you can read bigJSON data by google’ GSON library,
      or you can write own parser.

  5. rajesh

    November 29, 2013

    Hi lokesh, i like java programming. java programming is my hobby.
    i have stuk in some implementation.
    i want to use rest service with hibernate.
    i have two or more database.
    is it right or best way implement this combination for performance wise?
    or which design pattern should i folllow?
    please reply

    • Lokesh Gupta

      November 29, 2013

      I didn’t get your question properly. What you are trying to achieve by two databases? Will they store same data or different data? What kind of data they will store? What are possible performance bottlenecks do you anticipate?

      • rajesh

        December 2, 2013

        hi lokesh lets assume i am going to develop a portal,in this portal,i have two or more database, 1st database contain user information and 2 nd database contain user’s data.
        lets example. i have a webservice that provide user’s store data on server.
        that’s service access by mobile.
        one user can have multiple device so user can store data from different different device to server but user is one so i have created two database
        one for user information(account management,billing functionality) and 2nd database is used for store user’s data.so if we have 3 user then we will create 4 database 1 database is used for store information of users and 3 database for user’s information.
        i will store data form of table in pgsql.
        so please tell me should i follow any design pattern?or or ORM tool.
        please give me reply as soon as.

        thanks
        raj

        • Lokesh Gupta

          December 2, 2013

          Why are you creating separate databases? Whats problem in having single database with two or more tables? I am not able to understand what you are trying to achieve with multiple databases. If your view layer clients are different, then how it impacts your data stored in database?

          • rajesh

            December 10, 2013

            Hi lokesh,my intetation is for seprate-2 db for seprate-2 user.then use can take backup via web service of own db.lets assume i have developed one app that able to store own data on server.two user use simultaneous this app,so table name and structure is same.i can manage by userid field existing in table. that time i decided for seprate db.
            is it not good?

            • Lokesh Gupta

              December 10, 2013

              In my view, you should not create multiple databases. Your app will be executed on server, and mostly they share lots of common data. It is not good idea to duplicate this data into multiple places.
              Whenever an app is installed on server, it should create some of it’s own tables which will have unique information around this app only. Some table naming convention can be used e.g. TBL_AppID_MyTable. This way all apps will have some of common tables and some of their unique tables.
              Every appuser must have authority/permissions only on common tables and it’s own tables. Other tables it must not even list/count/fetch or whatever.

              During backup, you know which all tables you need to backup [common + starting with “TBL_AppID_”].

              https://howtodoinjava.com/mysql/managing-users-from-console-in-mysql-database/

          • rajeshboy44

            December 12, 2013

            Thanks lokesh.got it.

  6. Ummer

    July 25, 2013

    Hi Lokesh,
    Awesome tutorials bro, sharing knowledge will strength your knowledge,carry on.

  7. mankeomorakort

    June 26, 2013

    Hi guy, i am really appreciate your tutorials. could you create an article about authentication with web-service. my idea is that: if any user want to access url (esp. Resful web services), they must have authentication.

    Thank.

    • Lokesh Gupta

      June 26, 2013

      This is already on top of list. Probably in this week itself, I will be posting something on authentication.

      • mankeomorakort

        June 26, 2013

        thank, it will be useful for me 🙂

  8. Ravindra

    May 11, 2013

    That’s a good effort already !! Waiting for more such posts.

Comments are closed on this article!

Search Tutorials

RESTEasy Tutorial

  • JAX-RS – Introduction
  • RESTEasy – JBoss
  • RESTEasy – Tomcat
  • RESTEasy – @Path
  • RESTEasy – HATEOAS
  • RESTEasy – SLF4J
  • RESTEasy – Log4j
  • RESTEasy – Download
  • RESTEasy – Upload (MultipartForm)
  • RESTEasy – Upload (HTTPClient)
  • RESTEasy – Custom Validation
  • RESTEasy – Hibernate Validator
  • RESTEasy – ContainerRequestFilter
  • RESTEasy – PreProcessorInterceptor
  • RESTEasy – JAXB XML
  • RESTEasy – Jettison JSON
  • RESTEasy – Jackson JSON
  • RESTEasy – ExceptionMapper

RESTEasy Client APIs

  • RESTEasy – java.net
  • RESTEasy – JAX-RS Client
  • RESTEasy – Apache HttpClient
  • RESTEasy – JavaScript API
  • RESTEasy – ResteasyClientBuilder

RESTEasy Best Practices

  • RESTEasy – Sharing Context Data
  • RESTEasy – Exception Handling
  • RESTEasy – ETag Cache control
  • RESTEasy – GZIP Compression
  • RESTful vs. SOAP

Meta Links

  • About Me
  • Contact Us
  • Privacy policy
  • Advertise
  • Guest and Sponsored Posts

Recommended Reading

  • 10 Life Lessons
  • Secure Hash Algorithms
  • How Web Servers work?
  • How Java I/O Works Internally?
  • Best Way to Learn Java
  • Java Best Practices Guide
  • Microservices Tutorial
  • REST API Tutorial
  • How to Start New Blog

Copyright © 2020 · HowToDoInjava.com · All Rights Reserved. | Sitemap

  • Sealed Classes and Interfaces