Problème de JSON avec JSP
Salut Mes Amis,
bain voila je ne sais pas vraiment ou est le problem ,,ca fait 3 heurs que j'essay de trouver le problem mais il parait que ca march pas ,,voila mon code.
jsonHTML
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="jquery-1.6.4.js"></script>
<script>
$(function(){
$.getJSON('jsonJSP.jsp', function(data){
alert(1);
//$("#container").html(data.nom);
});
});
</script>
</head>
<body>
<p id="container"></p>
</body>
</html> |
et mon fichier jsp qui recupere les donné
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
<%--
Document : jsonJSP
Created on : 10 nov. 2011, 12:37:59
Author : AJROUDI
--%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="java.sql.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%!
Connection con;
Statement st;
ResultSet res;
%>
<%
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc:oracle:thin:@://localhost:1521/xe", "test", "123");
JSONObject object = new JSONObject();
st = con.createStatement();
res = st.executeQuery("select * from test");
res.next();
object.put("nom", res.getString(1));
object.put("title", res.getString(2));
out.println(object);
//out.print(res.getString(1));
%>
</head>
<body>
</body>
</html> |
ca ecrit vraiment un text en json quand j'execute la page jsp toute seul mais
mon jquery ne le recupere pas .