uCosminexus Application Server, Web Service Development Guide
This subsection describes the request method identifiers supported by the JAX-RS engine.
The javax.ws.rs.DELETE annotation indicates that an annotated method processes an HTTP DELETE request. You can use the javax.ws.rs.DELETE annotation in:
The javax.ws.rs.GET annotation indicates that an annotated method processes an HTTP GET request. You can use the javax.ws.rs.GET annotation in:
The javax.ws.rs.HEAD annotation indicates that an annotated method processes an HTTP HEAD request. You can use the javax.ws.rs.HEAD annotation in:
When an HTTP HEAD request is received, the JAX-RS engine operates in the following priority sequence:
The following is an example of the root resource class that processes the HTTP HEAD request .
package com.sample.resources;
import javax.ws.rs.HEAD;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
//Root resource class
@Path("/root")
public class Resource {
//Resource method
@HEAD
public Response getValue() {
String customHeader = "foo";
String customHeaderValue = "bar";
int httpStatus = 200;
//Build the Response object by using ResponseBuilder
return Response.status(httpStatus).header(customHeader,
customHeaderValue).build();
}
}
|
Consider the context root of the Web application (WAR file) containing the root resource class com.sample.resources.Resource to be example, and that the Web application is published on a host named sample.com. In this example, the HTTP HEAD request corresponding to the URL http://sample.com/example/root is dispatched to the getValue() method. Even if the Response object returned by the getValue() method contains an entity body, the object is ignored.
The javax.ws.rs.OPTIONS annotation indicates that an annotated method processes an HTTP OPTIONS request. You can use the javax.ws.rs.OPTIONS annotation in:
The JAX-RS engine handles the HTTP OPTIONS request as follows:
The following is an example of the root resource class that processes the HTTP OPTIONS request:
package com.sample.resources;
import javax.ws.rs.OPTIONS;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
//Root resource class
@Path("/root")
public class Resource {
//Resource method
@OPTIONS
public Response getValue() {
String entity = "Some Contents";
String customHeader = "foo";
String customHeaderValue = "bar";
int httpStatus = 200;
//Build the Response object by using ResponseBuilder
return Response.status(httpStatus).header(customHeader,
customHeaderValue).entity(entity).build();
}
}
|
Consider the context root of the Web application (WAR file) containing the root resource class com.sample.resources.Resource to be example, and that the Web application is published on a host named sample.com. In this example, the HTTP OPTIONS request corresponding to the URL http://sample.com/example/root is dispatched to the getValue() method.
The javax.ws.rs.POST annotation indicates that an annotated method processes an HTTP POST request. You can use the javax.ws.rs.POST annotation in:
The javax.ws.rs.PUT annotation indicates that an annotated method processes an HTTP PUT request. You can use the javax.ws.rs.PUT annotation in:
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.