I would like to make a http get request which gets a json response. In that session response I would like to store a value into my session. How is this achievable?
Thanks
I would like to make a http get request which gets a json response. In that session response I would like to store a value into my session. How is this achievable?
Thanks
Here is the sample code. You'll have response in recvbuff.
<%@page import="java.io.*" %>
<%@page import="java.net.*" %>
<%
String recv;
String recvbuff;
URL jsonpage = new URL("http://www.yoursite.com/jsonresponse");
URLConnection urlcon = jsonpage.openConnection();
BufferedReader buffread = new BufferedReader(new InputStreamReader(urlcon.getInputStream()));
while ((recv = buffread.readLine()) != null)
recvbuff += recv;
buffread.close();
System.out.println(recvbuff);
%>