Retrieving query parameters in JAX-RS annotated method

The post explains different ways of retrieving query parameters in JAX-RS annotated method. Below is the complete code 1 package resource; 2 3 import javax.ws.rs.GET; 4 import javax.ws.rs.Path; 5 import javax.ws.rs.QueryParam; 6 import javax.ws.rs.core.Context; 7 import javax.ws.rs.core.MediaType; 8 import javax.ws.rs.core.Response; 9 import javax.ws.rs.core.UriInfo; 10 11 @Path(“webresource2”) 12 public class WebResource2 { 13 @GET 14 @Path(“queryParameters1”)… Continue reading Retrieving query parameters in JAX-RS annotated method

Marshaling a property as xml attribute

By default when marshaling to xml file, all properties are marshaled as elements. This default behaviour can be changed and this post explains how to do it. In this post I will marshall the below java bean class, and id property as its attribute. Country 1 package package1; 2 3 import javax.xml.bind.annotation.XmlAttribute; 4 import javax.xml.bind.annotation.XmlRootElement;… Continue reading Marshaling a property as xml attribute

Preventing a property from being marshalled to xml file

By default all properties of an instance are marshalled as elements in an xml file. As shown below.. Marshalling an Country insance with below class structure Country package package2; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class Country { private int id; private String name; private int population; public int getId() { return id; } public void setId(int… Continue reading Preventing a property from being marshalled to xml file