Evaluating request preconditions using Request objects

Using Java API for RESTful Web Services (JAX-RS), you can use the Request object to access request headers. The Request object provides methods for evaluating preconditions and for selecting the optimal response variant based on the request headers.

이 태스크 정보

By using an injected Request object with the JAX-RS runtime environment, you can easily evaluate HTTP headers preconditions. The @javax.ws.rs.core.Context annotation indicates that a context object is injected. The javax.ws.rs.core.Request is the interface of the object that you want to inject. The injected Request object is useful in evaluating HTTP header preconditions with dates, such as the If-Modified-Since value and entity tags such as If-Match.

You can also use the Request object when implementing advanced content negotiation. To learn more about content negotiation, read about using XML content in JAX-RS application requests and responses.

문제점 방지 문제점 방지: The granularity of dates used in HTTP headers is not as precise as some dates used in data sources.  For example, the precision for a date in a database row might be defined to the millisecond. However, the date in an HTTP header field is only precise to seconds. When evaluating HTTP preconditions, if you compare a java.util.Date object to the date in an HTTP header, the difference in precision might produce unexpected results. To avoid this problem, normalize the java.util.Date object before comparing to the date value in the HTTP header.gotcha

프로시저

결과

You have used the javax.ws.rs.core.Request object to evaluate the HTTP headers of an incoming request, and determine the proper response to the request.

태스크 주제    

Information Center 이용 약관 | 피드백

마지막 업데이트 날짜: January 06, 2015 04:37 AM EST
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=phil&product=was-base-iseries&topic=twbs_jaxrs_contextobjects_request
파일 이름: twbs_jaxrs_contextobjects_request.html