my piece of code is
@POST
@Path("/getJSONCompareData")
@Produces(MediaType.APPLICATION_JSON)
public Object getJSONCompareData(@FormParam("testRunNum") String TRun,@FormParam("rptName") String reportName) {
if(debugLevel>2)
Log.debugLog(className, "getJSONStatsData", "", "", "Methad called");
Object obj=null;
try {
int testRunNum = Integer.parseInt(TRun);
String rptName = reportName;
JSONParser parser=new JSONParser();
String statsReportNameDir = Config.getWorkPath() + "/webapps/logs/TR" + testRunNum + "/reports/compareReports/" + rptName + "/compare.report";
obj=parser.parse(new FileReader(statsReportNameDir));
}catch(Exception e){
e.printStackTrace();
Log.stackTraceLog(className, "getJSONStatsData", "", "", "Exception - ", e);
}
return obj;
}
file size i am reading is approx 10MB
i want to compress data as it is taking 1 min over network
How i compress my Obj and handle in ajax call
You can compress JSON response using GZIP configuration on server.
Modern browsers supports gzip compressed content also Servers like Apache, Tomcat, JBoss etc supports gzip compression too.
Hence if gzip is enabled in server, it compress's data then sends to client.
you can refer article http://viralpatel.net/blogs/enable-gzip-compression-in-tomcat/
GZIP compression will increase performance not only for js,jsp files but also for http requests as data will be compressed