3:13 pm - Thursday December 17, 5553

JSON Array With JSP

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

Project Structure:

 

 

 

 

 

  

JARFiles: 

 

 

 

JSONArrayJsp.jsp:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"
	import="org.json.JSONArray,org.json.JSONException"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<h2>JSON in JSP</h2>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body bgcolor="pink">
<%
	JSONArray arrayObj = new JSONArray();
	arrayObj.put("name :");
	arrayObj.put("Deepa");
	arrayObj.put("Reg No");
	arrayObj.put(123);
	arrayObj.put("Mark");
	arrayObj.put(new Double(90));
	arrayObj.put("City");
	arrayObj.put("Chennai");

	out.println(arrayObj);
	out.println();

	int length = arrayObj.length();
	String opt = arrayObj.optString(2);
	boolean data = arrayObj.isNull(3);
	String getMark = arrayObj.getString(5);
	Object ob = arrayObj.get(7);
%>
<br />
<%
	out.println("Length: " + length);
%>
<br />

<%
	out.println("2nd Position: " + opt);
%>
<br />
<%
	out.println("isNull 3d position: " + data);
%>
<br />
<%
	out.println("Mark:" + getMark);
%>
<br />
<%
	out.println("City: " + ob);
%>
</body>
</html>

OUTPUT:

DOWNLOAD+SOURCECODE

Filed in: Z-A JSON codes

Comments are closed.