File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Portals and Portlets and the fly likes How to implement Pagination in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "How to implement Pagination in JSP" Watch "How to implement Pagination in JSP" New topic

How to implement Pagination in JSP

rajen prasad

Joined: Aug 16, 2006
Posts: 15
Hi All ,
I am using JSR168 portlets and MVC architecture to implement pagination portlet.

Anybody can you send me code to implement pagination in JSP???

What I am trying is when the user is not selected any page or the page is first time requested then I am displaying page no 1 .

Thanks in advance,
[ September 01, 2006: Message edited by: Bear Bibeault ]
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

You're trying to control which pages they see when?

Maybe some state logic. Put a flag in the user' session. If the flag is true, show them page 1, if it's false, show them page 2. Figure out which condition to change the flag on.

Not sure if this is what you're asking. Remember, you should allow the portal to decide which pages to render as much as possible. That's the mind shift you must make when you move to portal. Trying to control pages in the portal is a difficult matter - thus the creation of things like Struts Portlets and JSF portlets.
rajen prasad

Joined: Aug 16, 2006
Posts: 15
Hi ,
My scenario is like ---> When you search something in google then it should display some no of results in first page , next page , previous page . Like this I want to develop JSP .

Anyone can help me please

thanks in advance,
Rajendra Prasad
Pavan Kumar gorakavi

Joined: Nov 09, 2005
Posts: 4
You can implement your scenario as follows:

1. Have the pagination variable in property file, such that you can dynamically change the value.
2. create an class with Collection of search results, total results, currentPageNumber.
3. write a business logic by keeping track of on which page the user resides and pagination variable in property file.

This solution is universal in application, can be used in all portal environments.

Pavan Kumar Gorakavi
I agree. Here's the link:
subject: How to implement Pagination in JSP
jQuery in Action, 3rd edition