affichage des données d'une classe java dans une page JSP
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:
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 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:
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 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
|
<%@page import="java.io.*,testont.affichefeedback" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Eta9yim</title>
<link href="ontolologycss.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="topPan">
<div id="topHeaderPan">
<ul>
<li class="company">Companie</li>
<li><a href="cours.jsp">Cours</a></li>
<li><a href="partner.jsp">Espaces</a></li>
<li class="faq"><a href="faq.jsp">FAQ </a></li>
</ul>
<a href="index.jsp"><img src="images/logo.jpg" title="E-ta9yim" alt="E-ta9yim" width="191" height="84" border="0" /></a> </div>
<div id="toprightPan">
<ul>
<li class="home"><a href="index.jsp">Accueil</a></li>
<li class="about"><a href="about.jsp">A propos nous</a></li>
<li class="contact"><a href="contact.jsp">Contact</a></li>
</ul>
</div>
</div>
<div id="bodyPan">
<div id="bodyleftPan1">
</br>
</br>
<div id="lescours">
<div id="liens">
<a href="learner.jsp" ><p><input value="Mes Feedback" id="lien" type="submit"/></p></a>
<a href="tutor.jsp" ><p><input value="Mes Notes" type="submit" id="lien"/></p></a>
<a href="admin.jsp" ><p><input value="Mes Points Accumulés " type="submit" id="lien"/></p></a>
<a href="learner.jsp" ><p><input value="Mon Score" id="lien" type="submit"/></p></a>
<a href="tutor.jsp" ><p><input value="Ma Classification" type="submit" id="lien"/></p></a>
<a href="admin.jsp" ><p><input value="Performance de classe" type="submit" id="lien"/></p></a>
<a href="admin.jsp" ><p><input value="Commentaires des pairs" type="submit" id="lien"/></p></a>
</div>
</br>
<center>
</br>
<div id="feed"> <p id="espace"></br> <b> Espace de Réponse </b> </p> </div>
<img src="images/bra.gif" title="E-ta9yim" alt="ta9yim feedback" width="191" height="84" border="0" />
<p>
<p>Aujourdhui: <%= new java.util.Date() %> </p>
</br>
<% affichefeedback feedback=new affichefeedback();
feedback.main(null);
%>
<% %>
resultat lenna
                       
</center>
</div>
</div>
<div id="bodyrightPan">
<div id="servicesBottomPan5"> </div>
</div>
</div>
<div id="footermainPan">
<div id="footerPan">
<div id="footerlogoPan"><a href="index.html"><img src="images/footerlogo.gif" title="E-ta9yim" alt="E-ta9yim" width="189" height="87" border="0" /></a></div>
<ul>
<li><a href="index.jsp">Accueil</a>| </li>
<li><a href="about.jsp">A propos nous</a>|</li>
<li><a href="programme.jsp">Programmes</a>|</li>
<li><a href="cours.jsp">Cours</a>|</li>
<li><a href="partner.jsp">Partnaires</a>|</li>
<li><a href="faq.jsp">FAQ</a>|</li>
<li><a href="contact.jsp">Contact</a> </li>
</ul>
<p class="copyright">© E-ta9yim. All rights reserved.</p>
<ul class="templateworld">
<li>design by:</li>
<li><a href="#" target="_blank">Heni Sinda</a></li>
</ul>
</div>
</div>
</body>
</html> |