0

I have a Java Webapplication using jersey rest which gets deployed on a local tomcat server. This application is developed and tested within eclipse IDE.

Now in aptana IDE I have a AngularJS webapp which should connecct (using REST) to the jersey webapplication.

What steps do I have to make to establish the connection? Out of the box its not running because of the different contexts.

My current angularJS call:

WinesApp.factory('Wine', function ($resource) {
    return $resource('/WinesApp/rest/wines/:wineId', {}, {
        update: {method:'PUT'},
        query: {method:'GET', isArray:false}
    });
});

Which should become somethign like:

WinesApp.factory('Wine', function ($resource) {
    return $resource('http://localhost:port/WinesApp/rest/wines/:wineId', {port:':8080'}, {
        update: {method:'PUT'},
        query: {method:'GET', isArray:false}
    });
});

Greets Marc

1 Answer 1

2

For CORS to work you need to send the appropriate headers from the server: for Jersey, see for exmaple Java/Jersey: A CORS-Compliant REST API. Then you simply call it from JavaScript like you wrote (while not strictly RESTful, it's easier to restrict your API to use GET and POST requests only, no PUT and DELETE). Finally, the curl command line utility comes in handy to test the server.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.