Athul Sukumaran Athul Sukumaran - 1 year ago 137
reST (reStructuredText) Question

java:Tomcat 9 status code 200 but response message null

I have an http client that sends request to a RESTful web service and receives a response. It was working successfully when deployed in Tomcat 8. But when I tried to deploy the same client and server in Tomcat versions 8.5 and above, the server receives response code as 200 but response message is null instead of OK.

Below is my client code snippet

httpclient = HttpClientBuilder.create().build();
postrequest.setEntity(new UrlEncodedFormEntity(urlParameters));
HttpResponse response = httpclient.execute(postrequest);

HttpEntity entity = response.getEntity();
System.out.println("Response from server ");

and my server code snippet for response is

public Response getFile(@PathParam("filename") String file)
File downloadfile = new File("/home/upload/"+file);

ResponseBuilder response = Response.ok((Object) downloadfile);
response.header("Content-Disposition", downloadfile.getName());


catch(Exception e)
logger.error("Error is : "+e);


The output I get is just

Response from server


It should actually be

Response from server



Answer Source

As per the reported issue in tomcat, they have stopped sending "Reason Phrase" from tomcat 8.5 version onward.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download