On Apr 15, 2010, at 4:00 AM, Pavel Bucek wrote:
> Hello Suchitha,
>
> I don't think that the last value ("0") is status code. I guess it means "end of message", like in a c-string.
>
Right, the 10 and 0 are due to the use of chunked transfer encoding.
Marc.
> Status code is present elsewhere - see first line of output you provided:
>
> *HTTP/1.1 400 Bad Request
>
> *Regards,
> Pavel
>
>
> Suchitha Koneru (sukoneru) wrote:
>>
>> Hello Jersey users ,
>>
>> I am using Jersey 1.1.1-ea with JDK 1.6. We are using custom exception class along with exception mapper as shown below
>>
>>
>>
>> public class SmartServicesRSException extends WebApplicationException {
>>
>>
>> public Response.Status httpStatus;
>>
>>
>> public String applicationErrCode;
>>
>>
>>
>> public SmartServicesRSException(int httpStatusCode , String applicationErrCode){
>>
>> super(httpStatusCode);
>>
>> this.applicationErrCode = applicationErrCode;
>>
>> this.httpStatus = Response.Status.fromStatusCode(httpStatusCode);
>>
>> }
>>
>>
>> }
>>
>>
>>
>>
>> @Provider
>>
>> *public* *class* SmartServicesExceptionMapper *implements* ExceptionMapper<SmartServicesRSException>{
>>
>>
>> *public* Response toResponse(SmartServicesRSException exception) {
>>
>> // *TODO* Auto-generated method stub
>>
>> System./out/.println("the application error code is :"+exception.applicationErrCode);
>>
>> *return* Response./status/(exception.httpStatus).entity(*new*GenericEntity<String>(exception.applicationErrCode){}).type("application/text").build();
>>
>>
>> }
>>
>> }
>>
>>
>>
>> The TCP trace captured in the run time shows a status code of 0 , even when I am passing a valid HTTP status code as shown below
>>
>>
>>
>> @GET
>>
>> @Path("400")
>>
>> @Produces("application/text")
>>
>> *public* String testBadRequest() *throws* SmartServicesRSException {
>>
>> *throw* *new* SmartServicesRSException(Response.Status./BAD_REQUEST/,"input.error.code");
>>
>> }
>>
>>
>>
>> _TCP Response trace_
>>
>>
>> HTTP/1.1 400 Bad Request
>>
>> Server: Apache-Coyote/1.1
>>
>> X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
>>
>> Content-Type: application/text
>>
>> Transfer-Encoding: chunked
>>
>> Date: Thu, 15 Apr 2010 05:58:52 GMT
>>
>> Connection: close
>>
>>
>> 10
>>
>> input.error.code
>>
>> *0*
>>
>>
>> Could you please let me know , if there is anything missing in my approach. The status code is sent as 0 as per the last line of the output.
>>
>>
>> Thanks,
>>
>> Suchitha
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>