bonjour, j'ai développé une classe java dans laquelle j'ai mis des requetes SPARQL, ma classe fonctionne correctement, et affiche le resultat dans la console de netbeans. je voudrai afficher ce resultat dans une page JSP. (Rq: c'est une classe java simple n'est pas une servelet) et merci.
voici le code de ma classe JAVA:
Code : Sélectionner tout - Visualiser dans une fenêtre à part 
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package testont; import com.hp.hpl.jena.ontology.OntModelSpec; import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.util.IndentedWriter; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.util.FileManager; import com.hp.hpl.jena.vocabulary.RDF; public class affichefeedback{ public static final String owlFile = "C:/feedback.owl"; public static final String NL = System.getProperty("line.separator") ; public static void main( String[] args ) { /** * */ // Creation d'un modele d'ontologie pour une ontologie OWL-DL avec un resonneur RDFS Model m = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RDFS_INF); // Lecture du fichier OWL. Le Namespace de notre ontologie doit etre specifié FileManager.get().readModel( m, owlFile ); String myOntologyName = "feedback"; String myOntologyNS = "http://www.semanticweb.org/ontologies/2014/9/Ontology1413975071695.owl#"; // Définition de prefixe pour simplifier l'utilisation de SPARQL String rdfPrefix = "PREFIX rdf: <"+RDF.getURI()+">" ; String myOntologyPrefix = "PREFIX "+myOntologyName+": <"+myOntologyNS+">" ; // Construction de la requete String queryString = myOntologyPrefix + NL + rdfPrefix + NL + "SELECT ?typefeedback ?valuefeedback WHERE {?d feedback:valuefeedback ?valuefeedback ." + " ?d feedback:typefeedback ?typefeedback .}" ; Query query = QueryFactory.create(queryString) ; // Affichage de la requete sur la sortie standard. query.serialize(new IndentedWriter(System.out,true)) ; System.out.println() ; // Create a single execution of this query, apply to a model // which is wrapped up as a Dataset QueryExecution qexec = QueryExecutionFactory.create(query, m) ; // Execution de la requete try { // Pour l'instant nous nous limitons a des requetes de type SELECT ResultSet rs = qexec.execSelect() ; // Affichage des resultats for ( ; rs.hasNext() ; ){ QuerySolution rb = rs.nextSolution() ; RDFNode y = rb.get("valuefeedback"); RDFNode z = rb.get("typefeedback"); System.out.print(""+z+" : \n"+y+"\n -------------------------------------------------------------\n "); } } finally{ qexec.close() ; } }}
voici le code de ma page JSP
Code : Sélectionner tout - Visualiser dans une fenêtre à part 
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

 

 
		
		 
        

 
			
			
 
   
 


 affichage des données d'une classe java dans une page JSP
 affichage des données d'une classe java dans une page JSP
				 Répondre avec citation
  Répondre avec citation
Partager