0

Am trying to get request source ip with annotation @JsonProperty("IP") which not populating values.

Hi , I wrote web application using ResteasyBootstrap to receive and process http request with post parameters. ex: client send the product details in post parameters to server url. below is the sample

@Path("/json/Product")

public class Prodcut {

@POST

@Path("/post")

@Produces("application/json")

public Product getProductInJSON(Product product) {

           System.out.println(product.toString());


    String respMsg=processProduct(product);// process product

    product.setResponseMessage(respMsg);

     String JsonRespString=new Gson().toJson(product);

    return Response.status(201).entity(JsonRespString).build();

}

    public class Product{


 @JsonProperty("name")

  private String name;

   @JsonProperty("msgid")

      private String msgId;

/*setters gettes */

  @Override

public String toString() {

    return "{\"msgid=\":\"" + this.msgId + "\" , \"name\":\"" + this.name +""/

}"; }

now how do i get ip of client. Suggest me

GP32
  • 114
  • 1
  • 8
  • 2
    You're going to have to work on your question. Add some context. What does the JSON look like? How are you deserializing it? – Sotirios Delimanolis Feb 27 '14 at 23:59
  • JSON is a data format. It's used for exchanging data (sending and receiving) in a simple and clearly defined format. It has no notion of an IP address. (Clarify your question please) – KyleM Feb 28 '14 at 00:09

1 Answers1

0

If you are looking for the client IP, then use the @Context to get the request. Then something of what is here: Getting IP address of client

Community
  • 1
  • 1
codesalsa
  • 882
  • 5
  • 18