0

Returing a JSONObject right now from a restful webservice using Jersey. Its working perfectly fine and returning a JSSONObject as follows.

@GET
@Path("/LoginGetValues")
@Produces({"application/x-javascript"})
public JSONObject GetValues(@QueryParam("request") String request)
  { ...
          JSONObject value = new JSONObject();
          value = null ;
          return value ;
         }

But intending to convert that response into JsonP response , tried to append that with a callback function (as the following refering ( here) but then not getting the required response , indeed its asking to define the @JSONP annotation . Also if i have to define the callback then how and where i have to do that ! Kindly help to get a JSONP response

@GET
@JSONP(queryParam="callback")
@Path("/LoginGetValues")
@Produces({"application/x-javascript"})
public JSONWithPadding GetValues( @QueryParam("callback") String callback ,@QueryParam("request") String request)
  { ...
          JSONObject value = new JSONObject();
          value = null ;
         return new JSONWithPadding(value , callback);
         }
Community
  • 1
  • 1
Learner
  • 800
  • 1
  • 12
  • 34
  • why using @JSONP, you already using the method return of JSONWithPAdding type – ajitksharma Nov 27 '14 at 05:56
  • [Enable CORS](http://enable-cors.org/) instead. JSONP is unsafe and over complicated to get it right without a third party lib like jQuery or anything else. With CORS you can send anything (binary, plain text) not just json data. and you get progress and abortion as a bonus – Endless Dec 04 '14 at 13:59

0 Answers0