Action and Jsp to get an iterator and display it

This is my action class

public Iterator<CgConsultant> getSearchresult() {

        List<CgConsultant> list =userSearch.getConsultantMatches(searchstring);
        System.out.println("The size of the resutl list:"+list.size());
        Iterator<CgConsultant> iterator = list.iterator();
        CgConsultant obj;
        while(iterator.hasNext()){
            obj = (CgConsultant)iterator.next();
            System.out.println(obj.getUsername());
            System.out.println(obj.getFirstName());
            System.out.println(obj.getLastName());
        }
        return iterator;
    }

      

And I need to fill data in jsp and display it in jsp

I am getting the return status, but how do I fill n data showing it.

this is my jsp

<head>
    <title><fmt:message key="signup.title"/></title>
    <meta name="heading" content="<fmt:message key='signup.heading'/>"/>
</head>

<body>

        <h1> Search Complete</h1>
        <h2> Details are..</h2><br>

        <s:property value="Searchresult"/>

</body>
</html>

      

Please include any suggestion ..

+1


source to share


1 answer


Taglib c http://java.sun.com/jsp/jstl/core

            <c:forEach items="${Searchresult}" var="cgConsultant">
                    <c:out value="${cgConsultant.username}"/>
                    <c:out value="${cgConsultant.firstName}"/>
                    <c:out value="${cgConsultant.lastNameName}"/>
            </c:forEach>

      



Add some nice html

0


source







All Articles