Pager Tag library

For my current project we are using Pager tag library.
Everything is working fine.

We have a new requirement. Let me explain you with an example.
Let’s say I have a list with say some 10 pages.
1. User is currently viewing 6th page.
2. He than clicks on some other link in the browser.
3. Later he comes back to the listing page. Here the requirement is to show him the 6th page which he was previous looking it.

Current functionality takes him to the first page.
Can this be achieved using pager tag library?

I am guessing that the pageNumber is reset to 1 and I am not sure how to retain previous page number.
I would appreciate if you could explain me more on how the values to the implicit variables are set.
And also how can I meet my requirement using pager tag library.

Early Response will be greatly appreciated.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If you want to store a variable across a users session then use the session variable

session.setAttribute("pageNumber", pageNumber);

Then get this value back at a later time on a different page using a ternary expression to prevent nullpointerexceptions
String pageNumber = session.getAttribute("pageNumber") != null ? session.getAttribute("pageNumber") : "" ;

You can then pass this value into the page libs to determine which page is viewed in the same way as if it came from a request parameter.
vsaritha_9Author Commented:
Thanks a lot bloodredsun.

I have followed same approach. With this approach, ,I can show current page number but I need to hold to the offset value aswell.

This is how paging is shown

All these are hyperlinks. For each of these links, a javascript function is called to which offset is passsed. The offset is calculated based on firstElement exported value of Pager tag library.

For Page tag library it is mandatory to send this page offset value to the URL so that Pager can calculate current page number and all other parameters.

One approach to this modify all URL's in the application to pass this offset as request parameter.
I am using struts. instead of touching any of these URL's, I was thinking, if can add this offset to request parameter in my action class would be great.
But I m not finding any methods in the ActionForward class to add request parameters.

Other approach is to not to use pager tag library at all.

I am kind of inclined towards first approach for now. If there is a limitation with struts to add a request parameter then I might go with the second approach.

I would appreciate if you could share some thoughts on this and also for first approach if you have any solution to add offset to request parameter would be a great help.

Thank you
vsaritha_9Author Commented:
I guess I can write one more JSP and have a JSP forward tag where I can set page offset value taking from session.
The name of this JSP would be the URL name that is refered by all other places and I need to rename original JSP page to some other name to which is used forward tag in earlier JSP.

PAQed with points refunded (50)

Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.