Skip to content
Advertisement

Link fires method multiple no. of times

The problem is that whenever I click the link Next page on Home.xhtml to goto getMoreStatusList Page, the function getMoreStatusList is called non-stop until it throws a index out of bound exception. I am even printing the value of index that I get from the session object statusindex and the string insidegetmorestatusList when inside the getMoreStatusList() method to the console ,I use the method results = results.subList(index,index+5); to create sublist but this line is getting called more than once and is throwing out of bound exception as the value of index gets incremented with each call.

1)Home.xhtml

    <h:head>    
    </h:head>

    <h:body class="thrColElsHdr">        


                <!--  -->
                <div class="items">
                    <div id="scroll_items">
                        <c:forEach var="p" items="#{statusBean.statusList}">
                              //Content

                        </c:forEach>

                    </div>
                </div>

    <a href ="getMoreStatusList.xhtml">Next page</a>
    </h:body>
    </html>

2) Status Bean(this contains the getMoreStatusList function)

 public class StatusBean {




                public List<Status> getStatusList() {
            FacesContext context = FacesContext.getCurrentInstance();
            HttpSession session = (HttpSession) context.getExternalContext()
                    .getSession(true);
            User user = (User) session.getAttribute("userdet");
            Query query = em.createQuery("SELECT s FROM Status s WHERE s.email='"
                    + user.getEmail() + "' ORDER BY s.timeMillis desc",
                    Status.class);
            List<Status> results = query.getResultList();

            Collections.sort(results);
            results = results.subList(0, 5);

            session.setAttribute("statusindex", 5);
            return results;

        }

        public List<Status> getMoreStatusList() {

            System.out.println("Inside getMoreStatusList");
            FacesContext context = FacesContext.getCurrentInstance();
            HttpSession session = (HttpSession) context.getExternalContext()
                    .getSession(false);
            User user = (User) session.getAttribute("userdet");
            Query query = em.createQuery("SELECT s FROM Status s WHERE s.email='"
                    + user.getEmail() + "' ORDER BY s.timeMillis desc",
                    Status.class);
            List<Status> results = query.getResultList();

            Collections.sort(results);
            int index = (int) session.getAttribute("statusindex");
            System.out.println(index);
            results = results.subList(index,index+5);
            session.setAttribute("statusindex", index + 5);
            return results;

        }


    }

3) getMoreStatusList.xhtml

<h:head></h:head>
<h:body>

            <c:forEach var="p" items="#{statusBean.moreStatusList}">

                      // Content
            </c:forEach>


</h:body>

</html>

3) Stacktrace(I have cut it short because the limit is 30000)

Inside getMoreStatusList
[EL Finest]: 2013-03-03 15:09:47.527--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.527--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.527--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [amlan@ymail.com]
[EL Finest]: 2013-03-03 15:09:47.529--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.529--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Friend sql="SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)")
[EL Finest]: 2013-03-03 15:09:47.529--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.529--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)
    bind => [amlan@ymail.com]
[EL Finest]: 2013-03-03 15:09:47.53--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.53--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.53--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.53--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [ramanujonlyme@gmail.com]
[EL Finest]: 2013-03-03 15:09:47.531--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.531--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.531--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.531--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [atinr4@gmail.com]
[EL Finest]: 2013-03-03 15:09:47.531--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
5
Inside getMoreStatusList
[EL Finest]: 2013-03-03 15:09:47.532--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.532--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.532--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [amlan@ymail.com]
[EL Finest]: 2013-03-03 15:09:47.533--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.533--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Friend sql="SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)")
[EL Finest]: 2013-03-03 15:09:47.534--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.534--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)
    bind => [amlan@ymail.com]
[EL Finest]: 2013-03-03 15:09:47.534--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.534--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.534--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.535--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [ramanujonlyme@gmail.com]
[EL Finest]: 2013-03-03 15:09:47.535--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.535--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.535--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.535--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [atinr4@gmail.com]
[EL Finest]: 2013-03-03 15:09:47.536--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
10
Inside getMoreStatusList
[EL Finest]: 2013-03-03 15:09:47.537--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.537--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.537--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [amlan@ymail.com]
[EL Finest]: 2013-03-03 15:09:47.538--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.539--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Friend sql="SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)")
[EL Finest]: 2013-03-03 15:09:47.539--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.539--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)
    bind => [amlan@ymail.com]
[EL Finest]: 2013-03-03 15:09:47.539--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.539--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.539--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.54--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [ramanujonlyme@gmail.com]
[EL Finest]: 2013-03-03 15:09:47.54--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.54--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.54--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.54--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [atinr4@gmail.com]
[EL Finest]: 2013-03-03 15:09:47.541--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
15
[EL Finest]: 2013-03-03 15:09:47.541--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Comment sql="SELECT COMMENTID, COMMENT, COMMENTBY, EMAIL, PICTURE, STATUSID, TIMEMILLIS FROM COMMENT WHERE (STATUSID = ?)")
[EL Finest]: 2013-03-03 15:09:47.541--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.541--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT COMMENTID, COMMENT, COMMENTBY, EMAIL, PICTURE, STATUSID, TIMEMILLIS FROM COMMENT WHERE (STATUSID = ?)
    bind => [61]
[EL Finest]: 2013-03-03 15:09:47.542--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
Inside getMoreStatusList
[EL Finest]: 2013-03-03 15:09:47.543--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.543--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.543--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [amlan@ymail.com]
[EL Finest]: 2013-03-03 15:09:47.544--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.545--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Friend sql="SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)")
[EL Finest]: 2013-03-03 15:09:47.545--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.545--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)
    bind => [amlan@ymail.com]
[EL Finest]: 2013-03-03 15:09:47.546--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.546--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.546--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.546--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [ramanujonlyme@gmail.com]
[EL Finest]: 2013-03-03 15:09:47.547--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.547--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.547--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.547--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [atinr4@gmail.com]
[EL Finest]: 2013-03-03 15:09:47.548--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
20
Inside getMoreStatusList
[EL Finest]: 2013-03-03 15:09:47.548--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.548--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.548--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [amlan@ymail.com]
[EL Finest]: 2013-03-03 15:09:47.549--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.549--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Friend sql="SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)")
[EL Finest]: 2013-03-03 15:09:47.549--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.55--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)
    bind => [amlan@ymail.com]
[EL Finest]: 2013-03-03 15:09:47.55--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.55--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.55--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.55--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [ramanujonlyme@gmail.com]
[EL Finest]: 2013-03-03 15:09:47.551--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.551--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.551--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.551--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [atinr4@gmail.com]
[EL Finest]: 2013-03-03 15:09:47.552--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
25
Inside getMoreStatusList
[EL Finest]: 2013-03-03 15:09:47.553--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.553--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.553--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [amlan@ymail.com]
[EL Finest]: 2013-03-03 15:09:47.554--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.554--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Friend sql="SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)")
[EL Finest]: 2013-03-03 15:09:47.554--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.554--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)
    bind => [amlan@ymail.com]
[EL Finest]: 2013-03-03 15:09:47.555--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.555--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.555--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.555--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [ramanujonlyme@gmail.com]
[EL Finest]: 2013-03-03 15:09:47.556--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.556--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.556--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.556--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [atinr4@gmail.com]
[EL Finest]: 2013-03-03 15:09:47.557--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
30
Mar 03, 2013 3:09:47 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/FreeBird_v.6] threw exception [/getMoreStatusList.xhtml @17,41 test="${p.statusmsg!=null}" /getMoreStatusList.xhtml @17,41 test="${p.statusmsg!=null}": /getMoreStatusList.xhtml @14,60 items="#{statusBean.moreStatusList}": Error reading 'moreStatusList' on type com.bean.StatusBean] with root cause
java.lang.IndexOutOfBoundsException: toIndex = 35
    at java.util.SubList.<init>(AbstractList.java:622)
    at java.util.RandomAccessSubList.<init>(AbstractList.java:775)
    at java.util.AbstractList.subList(AbstractList.java:484)
    at java.util.Vector.subList(Vector.java:1034)
    at com.bean.StatusBean.getMoreStatusList(StatusBean.java:191)
    at sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source)
    at ......

Advertisement

Answer

You should use <ui:repeat> (with xmlns:ui="http://java.sun.com/jsf/facelets") instead of <c:forEach>

foEach is a tag handler, repeat is a component. You can read more about the difference between the two on this blog

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
</h:head>
<h:body class="thrColElsHdr">
    <ui:repeat var="p" value="#{statusBean.statusList}">
        <div>
            <h:outputText label="Status" value="#{p.value}" />
        </div>
    </ui:repeat>
    <a href="getMoreStatusList.xhtml">Next page</a>
</h:body>
</html>

and

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head></h:head>
<h:body>
    <ui:repeat var="p" value="#{statusBean.moreStatusList}">
        <div>
            <h:outputText label="Status" value="#{p.value}" />
        </div>
    </ui:repeat>
    <a href="getMoreStatusList.xhtml">Next page</a>
</h:body>
</html>

to get rid of IndexOutOfBoudsException use the following in getMoreStatusList:

int index = (Integer) session.getAttribute("statusindex");
int end = index+5 > results.size() ? results.size() : index+5;
List<Status> subList = results.subList(index,end);
session.setAttribute("statusindex", end);

and in getStatusList:

int index = 0;
int end = index+5 > results.size() ? results.size() : index+5;
List<Status> subList = results.subList(0, end);
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement