protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String filename = "/WEB-INF/TesteLOM2.rdf";
ServletContext context = getServletContext();
InputStream in = context.getResourceAsStream(filename);
if (in != null) {
Model model = ModelFactory.createMemModelMaker()
.createDefaultModel();
model.read(in, null);
// null base URI, since model URIs are absolute
in.close();
@SuppressWarnings("unchecked")
List<String> lista = (List<String>) request.getSession()
.getAttribute("sugestao");
String palavrachave = null;
for (Iterator<String> iter = lista.iterator(); iter.hasNext();) {
palavrachave = iter.next();
// Creates a query....
String queryString =
// ( SPARQL stuff here...}
Query query = QueryFactory.create(queryString);
// get the results...
QueryExecution qe = QueryExecutionFactory.create(query, model);
ResultSet results = qe.execSelect();
request.setAttribute("results", results);
/*
* Compiler says error is in next line
* Got this exception: Cannot forward after response has been committed
* as I tried to forward results to a jsp page...
*/
request.getRequestDispatcher(VIEW).forward(request, response);
// ResultSetFormatter.out(System.out, results, query);
qe.close();
}
}
}