Search Java Code Snippets

  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.

#Java - Code Snippets for '#MediaType.APPLICATION_JSON' - 2 code snippet(s) found

 Sample 1. Rest Web Service ( Get ) using Jersey

public class RestWebServiceJersey {
public String getEmployeeInfo(@PathParam("employeeId") String employeeId) {
JSONObject jsonObj = new JSONObject();
jsonObj.put("EmployeeName", "Sam");
jsonObj.put("EmployeeDept", "Marketing");
return jsonObj.toString();

   Like      Feedback     rest  rest web service  jersey  @path  @get  @produces  MediaType.APPLICATION_JSON  @PathParam  JSONObject  javax.json.JSONObject

 Sample 2. Implementation of com.sun.jersey.api.core.DefaultResourceConfig

public class MyConfig extends DefaultResourceConfig {

private final Set<Class<?>> classes =
ImmutableSet.<Class<?>>of(SampleResource1.class, SampleResource2.class);

private final Set<Object> singletons =
new JacksonJaxbJsonProvider().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true), new KryoProvider<Object>()

private final Map<String, MediaType> mediaTypeMapppings = ImmutableMap.of("json", MediaType.APPLICATION_JSON_TYPE);

public MyConfig() {

public Set<Class<?>> getClasses() {
return classes;

public Set<Object> getSingletons() {
return singletons;

public Map<String, MediaType> getMediaTypeMappings() {
return mediaTypeMapppings;

   Like      Feedback     Implementation of DefaultResourceConfig   jersey

Subscribe to Java News and Posts. Get latest updates and posts on Java from
Enter your email address:
Delivered by FeedBurner