I have one method, this method returnes a list of items, inside java bean it works now I want to print the output of the method inside jsp, but I searched a lot couldn't find something useful, if someone can help me I really appreciated this is my method for print a list
public static List printDirect() {
List returned_list = new ArrayList ();
//StringBuilder text=new StringBuilder();
manager = OntologyManagement.ontology.getOWLOntologyManager();
factory = manager.getOWLDataFactory();
reasonerFactory = new StructuralReasonerFactory();
progressMonitor = new ConsoleProgressMonitor();
config = new SimpleConfiguration(progressMonitor);
reasoner = reasonerFactory.createReasoner(ontology, config);
// Ask the reasoner to do all the necessary work now
reasoner.precomputeInferences();
OWLClass thing = factory.getOWLThing();
NodeSet<OWLClass> subClses = reasoner.getSubClasses(thing, true);
Set<OWLClass> clses = subClses.getFlattened();
System.out.println("Subclasses of owl:thing = ");
for (OWLClass cls : clses) {
String row = cls.toString();
String[] split = row.split("#");
String word = split[1].substring(0, (split[1].length() -1));
returned_list.add(word);
System.out.println(" " + word);
}
return returned_list;
}
First get the List object in jsp like this
<%
List list = fullQualifiedClassName.printDirect();
%>
Then iterate over the listObject using JSTL
<c:forEach items="${list}" var="item">
${item}<br>
</c:forEach>
Dont forget to add this along with the necessary imports
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
You can even use simple Scriptlets
to iterate over the List
(But it is not Recommended)
<% for (int i=0;i<list.size();i++)
{
out.println(list.get(i));
}
%>
or
<% Iterator iterator = list.iterator();
while (iterator.hasNext()) {
out.println(iterator.next());
}
%>