displaying results

hi every body this is ram

I have an issue. I am trying to display 5 records in a jsp and place a button for the remaining as in google search results but it should not get submited to the same page instead it should display at the same place by clearing the previous once

Kindly help me Please

Thanks

Message was edited by:

bache

[368 byte] By [bachea] at [2007-11-27 3:51:03]
# 1

To start you off. you could use scriptlets in a jsp page to control the amount of records displayed but i would recomend using JSTL with a backing bean.

Store the list of your records in the backing bean and use the JSTL tag <c:foreach> to loop through them the foreach has got useful attributes for pagination namely the begin and end attributes. In your backing bean you will just need to keep count of where in your list you are. Simple Example:

<c:forEach var="record" items="${bean.results}" begin="${bean.startIndex}" end="${bean.endIndex}">

${record}

</c:forEach>

you will need a next control that will reload the page eg:

<a href="results.jsp?next=true" title="scroll to next page">

<img src="/imgs/next.gif"></a>

You will need something like this at the top of your results.jsp

<c:if test="${!empty param.next}">

<% bean.next(); %>

</c:if>

In your backing bean you will need to keep track of what page you are on and also make a check to see if you need to increase or decrease the start or end indexs in your results list.

josephquinn80a at 2007-7-12 8:55:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

If you wanna learn how you need to implement that from scratch use the link below

http://www.javaworld.com/javaworld/jw-07-2004/jw-0726-pagination.html?page=2

else where here are few helpful taglibraries which can help you in solving the discussed problem

http://displaytag.sourceforge.net/11/

eg: http://displaytag.homeip.net/displaytag-examples-1.1/example-paging.jsp

http://jsptags.com/tags/navigation/pager/pager-taglib-2.0.html

watch out for page tag library under the below website.

http://www.servletsuite.com/jsp.htm

and for the best part checkout where many other had a similar problem.

http://onesearch.sun.com/search/onesearch/index.jsp?col=developer-forums&qt=pagination+JSP&qp_name=null&subCat=siteforumid%3Ajava45&site=dev&dftab=siteforumid%3Ajava45&chooseCat=javaall&cs=false&rt=true&st=11

Hope this might help :)

REGARDS,

RaHuL

RahulSharnaa at 2007-7-12 8:55:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...