Sunday, January 1, 2017

Java Post JSON data

GSON library is good tool to convert data to JSON format 1. Add GSON dependency, current latest version is 2.8.0 2. The data sender util look like:

How To Get Source IP Address from HttpServletRequest

The address of source of request is stored in the header of HttpServletRequest so it is simply to get it. If it is not available in header so we can get the RemoteAddress. Mark dependency to package javaee-web-api, current latest verion is 7.0 The util look like: