user93796
user93796

Reputation: 18379

jsp paging issue

I am using the redy made paging tags.B But it give me a error of null pointer exception. the first page is displayed correctly. But when I click next it gives the error

<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %>
<%

 Iterator i = null;
 Set <Tutorials> tutorials = (Set <Tutorials> ) request.getAttribute("tut_lst");
 request.setAttribute("tut_lst",tutorials);

  i =  tutorials.iterator();  // error occurs here

%>



 <pg:pager>
      <pg:param name="keywords"/>
<%


       while(i.hasNext())
       {
           Tutorials t = (Tutorials)i.next();

 %>
          <pg:item>

            <BR> <a href ="down?tid=<%out.println(t.getUploadid() );%> ">        <%out.println(t.getFilename()); %> </a></td>

        </pg:item>
<%

          }

%>

 <pg:index>

    <pg:first>
      <a href="<%= pageUrl %>">[ (<%= pageNumber %>) |&lt; Previous ]</a>
    </pg:first>

    <pg:prev>
      <a href="<%= pageUrl %>">[ (<%= pageNumber %>) &lt;&lt; Previous ]</a>
    </pg:prev>

    <pg:pages>
       <a href="<%= pageUrl %>"><%= pageNumber %></a>
    </pg:pages>

    <pg:next>
      <a href="<%= pageUrl %>">[ Next &gt;&gt; (<%= pageNumber %>) ]</a>
    </pg:next>

    <pg:last>
      <a href="<%= pageUrl %>">[ Last &gt;| (<%= pageNumber %>) ]</a>
    </pg:last>

  </pg:index>
</pg:pager>

Upvotes: 1

Views: 331

Answers (1)

Zack Marrapese
Zack Marrapese

Reputation: 12090

It looks like the new request isn't getting the tut_lst attribute.

Are you getting a null pointer exception?

edit: normally an attribute is set in session scope. Is there a reason you don't want to do this?

Upvotes: 1

Related Questions