1

I've been building a REST Web service, deployed in Tomcat7, with Java; and client with HTML/AngularJS.

@GET
@Path("/hello")
@Produces("plain/text")
public Response hello(){
    String hello="hello";
    return Response.status(Status.OK).entity(hello).build();
}

This simple method in server side seems to be working when invoked from browser using right URL (http://localhost:8080/some-path/hello) and gives hello as plain text.

Everthing seems right in Tomcat log files as well.

But, with this piece of code,

$http({ 
        url: 'http://localhost:8080/some-path/hello',
        method: 'GET'

        }).then(
            function (response){
                $scope.passCheck = response.data;
            },
            function (response){
                $scope.passCheck = response.status ;
            }
    );

I'm getting -1 status code (Always second response function executes).

Could anyone help me with this?

ismlhk
  • 11
  • 2
  • I assume that -1 is the status you're getting from angular. What is the response status that you're getting in your browser dev tools / network? – jbrown Jul 14 '16 at 15:09
  • @jbrown I couldn't understand what exactly you mean, but in tomcat log files, the status code is 200 as I said. I checked it with SoupUI and no problem there as well. 'response.status' expression gives -1 when opened in the browser. – ismlhk Jul 15 '16 at 06:16

1 Answers1

0

Solved after working on it whole day. The problem was I was not deploying html files together with the project itself. I created the same html file in the project and it worked fine.

ismlhk
  • 11
  • 2