Java

Java Functional Interface

1. What is Functional Interface An interface with only one abstract method is called Functional Interface. Pre Java 8, there was no concept of Functional Interface. However, interfaces like Comparator and Runnable have only one abstract method. Hence they fell into the Functional Interface category in Java 8 unintentionally. 2. Example 2.1 getSellingPrice method snippet …

Java Functional Interface Read More »

Jersey (JAX-RS) JSON HTTP entity payload processing example

JSON (JavaScript Object Notation) is the most used structured data interchange format of the current generation. It is very common for REST clients to use it for data exchange. Several web client frameworks (e.g. AngularJS) natively handle JSON requests and responses. Jersey (JAX-RS) JSON support is very effective and easy to use. Usually, clients send and receive JSON …

Jersey (JAX-RS) JSON HTTP entity payload processing example Read More »

Jersey (JAX-RS) single file upload example

Jersey provides an easy mechanism to let clients upload files to the server. In this tutorial, we will learn a single file upload to Jersey (JAX-RS) endpoint. 1. Include Jersey media multipart dependency in Gradle File: build.gradle (snippet) ….dependencies { compile ‘org.springframework.boot:spring-boot-starter-web’, ‘org.springframework.boot:spring-boot-starter-jersey’, ‘org.glassfish.jersey.media:jersey-media-multipart:2.+’, ‘org.springframework.boot:spring-boot-starter-jdbc’, ‘org.springframework.boot:spring-boot-devtools’, ‘com.h2database:h2:1.4.+’ testCompile ‘org.springframework.boot:spring-boot-starter-test’}…. Jersey provides multipart form data support …

Jersey (JAX-RS) single file upload example Read More »

Jersey (JAX-RS) @FormParam HTML form data handling

There are multiple ways for consuming HTML form data (application/x-www-form-urlencoded) in Jersey. Using @FormParam annotation we can inject Form values in the Resource method. We can use it just like other @*Param. Jersey resource method needs to know they have to handle HTML form data, for it we explicitly specify @Consumes(“application/x-www-form-urlencoded”). There are multiple ways in which we can handle …

Jersey (JAX-RS) @FormParam HTML form data handling Read More »

Spring Boot and Jersey (JAX-RS) static files support

In Spring Boot support for Jersey is provided by org.springframework.boot:spring-boot-starter-jersey Gradle dependency. When the static file URL pattern is matched with URLs that Jersey handles, additional configurations are required for Spring Boot to serve static resources. Note: We are using Gradle dependency management system, configuration for Maven will be similar. Add Spring Boot web starter dependency File : build.gradle (Snippet) dependencies { …

Spring Boot and Jersey (JAX-RS) static files support Read More »